Documentation ¶
Index ¶
- Variables
- func CSVDecoder(body io.Reader, v interface{}) error
- func Decode(r *http.Request, v interface{}) error
- func JSONDecoder(body io.Reader, v interface{}) error
- func MustDecode(r *http.Request, v interface{})
- func TOMLDecoder(body io.Reader, v interface{}) error
- func XMLDecoder(body io.Reader, v interface{}) error
- func YAMLDecoder(body io.Reader, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
var Decoders = map[string]func(body io.Reader, v interface{}) error{ "application/json": JSONDecoder, "application/yaml": YAMLDecoder, "application/toml": TOMLDecoder, "application/xml": XMLDecoder, "text/xml": XMLDecoder, "text/csv": CSVDecoder, }
Decoders are POST data decoders. The key is the content type, the value is a decoder that decodes the contents of the Reader into v.
var NoDecoderErr = errors.New("no decoder found for the request content type")
Functions ¶
func CSVDecoder ¶
CSVDecoder decodes the request body using the built-in CSV reader into v.
v must be *[][]string
func Decode ¶
Decode decodes a request body into v. After decoding, it closes the body.
This function considers only the Content-Type header, and requires its presence. See the Decoders variable for more information.
func JSONDecoder ¶
JSONDecoder decodes the request body using the built-in JSON decoder into v.
func MustDecode ¶
MustDecode is the same as Decode(), but it panics instead of returning an error.
When using the kit with the recommended settings, this method is recommended instead of Decode(), because the panic will get caught by the error handler middleware.
func TOMLDecoder ¶
TOMLDecoder decodes the request body using a TOML decoder into v.
func XMLDecoder ¶
XMLDecoder decodes the request body using the built-in XML decoder into v.
func YAMLDecoder ¶
YAMLDecoder decodes the request body using a YAML decoder into v.
Types ¶
This section is empty.