httpdecode

package
v0.0.0-...-4b7be03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

Decode decodes form URL encoded requests and JSON requests from r into v. Also decodes path (chi only) and query parameters.

The requests Content-Type header informs if the request should be decoded using a form URL encoded decoder or using a JSON decoder.

A Content-Type of application/x-www-form-urlencoded will result in form decoding. Any other content type will result in JSON decoding because it is common to make JSON requests without a Content-Type where-as correctly formatted form URL encoded requests are more often accompanied by the appropriate Content-Type.

An error is returned if the Content-Type cannot be parsed by a mime media-type parser.

See DecodePath, DecodeQuery, DecodeForm and DecodeJSON for details about the types of errors that may occur.

func DecodeForm

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

DecodeForm decodes form URL encoded requests from r into v.

The type of the value given can use `form` tags on fields in the same way as the `json` tag to name fields.

An error will be returned if the request is not a POST, PUT, or PATCH request.

An error will be returned if the request has a media type in the Content-Type not equal to application/x-www-form-urlencoded, or if the Content-Type header cannot be parsed.

func DecodeJSON

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

DecodeJSON decodes JSON request from r into v.

func DecodePath

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

DecodePath decodes parameters from the path in a request used with the github.com/go-chi/chi muxing module.

func DecodeQuery

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

DecodeQuery decodes the query string from r into v.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL