Bind 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 (e.g.,
(obj any)
| 755 | // It decodes the payload into the struct specified as a pointer. |
| 756 | // It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid. |
| 757 | func (c *Context) Bind(obj any) error { |
| 758 | b := binding.Default(c.Request.Method, c.ContentType()) |
| 759 | return c.MustBindWith(obj, b) |
| 760 | } |
| 761 | |
| 762 | // BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON). |
| 763 | func (c *Context) BindJSON(obj any) error { |
nothing calls this directly
no test coverage detected