Skip to content
Myr

Remove incorrect comments about context.Bind() and improve docs (#3028)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Waynerv · committed by GitHub · parent 1b28e2b · Browse files · 1 file+5 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−7 removed

  • other:+5 added−7 removed

1 file+5 added−7 removed

modified:context.go+5 added-7 removed
599 unmodified lines
600 _, err = io.Copy(out, src)601 return err602}603604// Bind checks the Content-Type to select a binding engine automatically,605// Depending on the "Content-Type" header different bindings are used:604// Bind checks the Method and Content-Type to select a binding engine automatically,605// Depending on the "Content-Type" header different bindings are used, for example:606// "application/json" --> JSON binding607// "application/xml" --> XML binding608// otherwise --> returns an error.608// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.609// It decodes the json payload into the struct specified as a pointer.610// It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid.611func (c *Context) Bind(obj interface{}) error {
46 unmodified lines
658 }659 return nil660}661663// ShouldBind checks the Content-Type to select a binding engine automatically,664// Depending on the "Content-Type" header different bindings are used:662// ShouldBind checks the Method and Content-Type to select a binding engine automatically,663// Depending on the "Content-Type" header different bindings are used, for example:664// "application/json" --> JSON binding665// "application/xml" --> XML binding667// otherwise --> returns an error666// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.667// It decodes the json payload into the struct specified as a pointer.670// Like c.Bind() but this method does not set the response status code to 400 and abort if the json is not valid.668// Like c.Bind() but this method does not set the response status code to 400 or abort if input is not valid.669func (c *Context) ShouldBind(obj interface{}) error {670 b := binding.Default(c.Request.Method, c.ContentType())671 return c.ShouldBindWith(obj, b)672}
499 unmodified lines