Skip to content

Commit

Permalink
fix: shouldBind instead of Bind to prevent abort (#830)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen de Kok <jeroen@weave.nl>
  • Loading branch information
jeroendk and jeroendk committed Nov 1, 2022
1 parent 7dead8e commit 050c4bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions internal/test/strict-server/gin/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 050c4bf

Please sign in to comment.