repository
0.0.0-20160121205837-a8bae0b66e09
Repository: https://github.com/marcsv/go-binder.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
binder
Simple package for binding of an HTTP request body easily to an struct.
Install
Donwload and install the package
$ go get -u github.com/marcsv/go-binder/binder
Usage
It supports the following media types: JSON, XML, form and multipart form.
type MyBody struct {
Foo string `json:"foo"`
Bar string `json:"bar"`
}
func handler(w http.ResponseWriter, r *http.Request) {
body := MyBody{}
err := binder.BindBody(r, &MyBody)
}
Just give it a pointer to the http.Request and a pointer to the struct to bind.