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

Method Bind

context.go:757–760  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
757func (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).
763func (c *Context) BindJSON(obj any) error {

Callers

nothing calls this directly

Calls 3

ContentTypeMethod · 0.95
MustBindWithMethod · 0.95
DefaultFunction · 0.92

Tested by

no test coverage detected