|
|
|
@ -38,6 +38,7 @@ func DefaultRequestQuery(r *http.Request, v any) error { |
|
|
|
|
} |
|
|
|
|
func DefaultRequestDecoder(r *http.Request, v any) error { |
|
|
|
|
codec, ok := CodeForRequest(r, "Content-type") |
|
|
|
|
fmt.Println(codec, ok) |
|
|
|
|
if !ok { |
|
|
|
|
return errors.BadRequest("CODEC", fmt.Sprintf("unregister Content-Type: %s", codec)) |
|
|
|
|
} |
|
|
|
@ -86,6 +87,7 @@ func DefaultErrorEncoder(w http.ResponseWriter, r *http.Request, err error) { |
|
|
|
|
} |
|
|
|
|
func CodeForRequest(r *http.Request, name string) (encoding.Codec, bool) { |
|
|
|
|
for _, accept := range r.Header[name] { |
|
|
|
|
fmt.Println(accept) |
|
|
|
|
codec := encoding.GetCodec(httputil.ContentSubtype(accept)) |
|
|
|
|
if codec != nil { |
|
|
|
|
return codec, true |
|
|
|
|