code refactoring

This commit is contained in:
2024-04-10 12:02:04 +02:00
parent 566f0f2ac2
commit 2f02293a52
6 changed files with 16 additions and 57 deletions

View File

@@ -17,9 +17,9 @@ type LoginRequest struct {
}
func Login(w http.ResponseWriter, r *http.Request) {
req := new(LoginRequest)
err := json.NewDecoder(r.Body).Decode(req)
if err != nil {
var req LoginRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}