DefaultDecoder detects the correct decoder for use on an HTTP request and marshals into a given interface.
(r *http.Request, v interface{})
| 22 | // DefaultDecoder detects the correct decoder for use on an HTTP request and |
| 23 | // marshals into a given interface. |
| 24 | func 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. |
| 42 | func DecodeJSON(r io.Reader, v interface{}) error { |
nothing calls this directly
no test coverage detected
searching dependent graphs…