Documentation
¶
Overview ¶
Package forms is for parsing http.Request form data
Usage:
func MyHandler(w http.ResponseWriter, r *http.Request) {
var body reqBody
if err := form.Decode(r, &body); err != nil {
w.WriterHeader(http.StatusUnprocessibleEnitity)
return
}
}
type reqBody struct {
Name string `form:"name"`
Age int `form:"age"`
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoHeaders = fmt.Errorf("error request doesnt contain the Content-Type: '%s'", contentTypeVal)
ErrNoHeaders is returned if the request doesnt contain the right content type for parsing the form
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder can decode any forms into a given object
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder will write form values into a http.Request
func NewEncoder ¶
NewEncoder returns a new Encoder and sets the content type header to the given request
Click to show internal directories.
Click to hide internal directories.