Do not decode JSON from body if no POST params are spec.
This commit is contained in:
@@ -28,6 +28,10 @@ var (
|
||||
_ = chi.URLParam
|
||||
_ = multipart.ErrMessageTooLarge
|
||||
_ = payload.ParseUint64s
|
||||
_ = strings.ToLower
|
||||
_ = io.EOF
|
||||
_ = fmt.Errorf
|
||||
_ = json.NewEncoder
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -72,6 +76,7 @@ func (r {{ export $.Endpoint.Entrypoint $a.Name }}) Get{{ export $p.Name }}() {{
|
||||
|
||||
// Fill processes request and fills internal variables
|
||||
func (r *{{ export $.Endpoint.Entrypoint $a.Name }}) Fill(req *http.Request) (err error) {
|
||||
{{ if $a.Params.Post }}
|
||||
if strings.ToLower(req.Header.Get("content-type")) == "application/json" {
|
||||
err = json.NewDecoder(req.Body).Decode(r)
|
||||
|
||||
@@ -82,6 +87,7 @@ func (r *{{ export $.Endpoint.Entrypoint $a.Name }}) Fill(req *http.Request) (er
|
||||
return fmt.Errorf("error parsing http request body: %w", err)
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{ if $a.Params.Get }}
|
||||
|
||||
Reference in New Issue
Block a user