fix: updated handlers to use new DecodeJSON generic function

This commit is contained in:
2026-08-14 16:58:52 +02:00
parent e0ab3bb51a
commit 93fd79560c
6 changed files with 20 additions and 69 deletions
-19
View File
@@ -1,26 +1,7 @@
package request
import (
"encoding/json"
"fmt"
"net/http"
)
type CreateUserPayload struct {
Email string `json:"email"`
Name string `json:"name"`
Password string `json:"password"`
}
func DecodeCreateUser(r *http.Request) (CreateUserPayload, error) {
var payload CreateUserPayload
decoder := json.NewDecoder(r.Body)
decoder.DisallowUnknownFields()
if err := decoder.Decode(&payload); err != nil {
return payload, fmt.Errorf("error decoding create user payload: %w", err)
}
return payload, nil
}