MCPcopy Create free account
hub / github.com/go-chi/render / DefaultDecoder

Function DefaultDecoder

decoder.go:24–39  ·  view source on GitHub ↗

DefaultDecoder detects the correct decoder for use on an HTTP request and marshals into a given interface.

(r *http.Request, v interface{})

Source from the content-addressed store, hash-verified

22// DefaultDecoder detects the correct decoder for use on an HTTP request and
23// marshals into a given interface.
24func DefaultDecoder(r *http.Request, v interface{}) error {
25 var err error
26
27 switch GetRequestContentType(r) {
28 case ContentTypeJSON:
29 err = DecodeJSON(r.Body, v)
30 case ContentTypeXML:
31 err = DecodeXML(r.Body, v)
32 case ContentTypeForm:
33 err = DecodeForm(r.Body, v)
34 default:
35 err = errors.New("render: unable to automatically decode the request content type")
36 }
37
38 return err
39}
40
41// DecodeJSON decodes a given reader into an interface using the json decoder.
42func DecodeJSON(r io.Reader, v interface{}) error {

Callers

nothing calls this directly

Calls 4

GetRequestContentTypeFunction · 0.85
DecodeJSONFunction · 0.85
DecodeXMLFunction · 0.85
DecodeFormFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…