MCPcopy
hub / github.com/gin-gonic/gin / ShouldBind

Method ShouldBind

context.go:838–841  ·  view source on GitHub ↗

ShouldBind checks the Method and Content-Type to select a binding engine automatically, Depending on the "Content-Type" header different bindings are used, for example: "application/json" --> JSON binding "application/xml" --> XML binding It parses the request's body based on the Content-Type (

(obj any)

Source from the content-addressed store, hash-verified

836// It decodes the payload into the struct specified as a pointer.
837// Like c.Bind() but this method does not set the response status code to 400 or abort if input is not valid.
838func (c *Context) ShouldBind(obj any) error {
839 b := binding.Default(c.Request.Method, c.ContentType())
840 return c.ShouldBindWith(obj, b)
841}
842
843// ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).
844//

Callers 2

Calls 3

ContentTypeMethod · 0.95
ShouldBindWithMethod · 0.95
DefaultFunction · 0.92

Tested by 2