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)
| 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. |
| 838 | func (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 | // |