Skip to content

Commit

Permalink
fix: shouldBind instead of Bind to prevent abort
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroendk committed Oct 28, 2022
1 parent 45eb6bd commit a96c0f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/codegen/templates/strict/strict-gin.tmpl
Expand Up @@ -35,7 +35,8 @@ type strictHandler struct {
{{if $multipleBodies}}if strings.HasPrefix(ctx.GetHeader("Content-Type"), "{{.ContentType}}") { {{end}}
{{if eq .NameTag "JSON" -}}
var body {{$opid}}{{.NameTag}}RequestBody
if err := ctx.Bind(&body); err != nil {
if err := ctx.ShouldBind(&body); err != nil {
ctx.Status(http.StatusBadRequest)
ctx.Error(err)
return
}
Expand Down

0 comments on commit a96c0f8

Please sign in to comment.