1 // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
2 // Use of this source code is governed by a MIT style
3 // license that can be found in the LICENSE file.
9 const defaultMemory = 32 * 1024 * 1024
11 type formBinding struct{}
12 type formPostBinding struct{}
13 type formMultipartBinding struct{}
15 func (formBinding) Name() string {
19 func (formBinding) Bind(req *http.Request, obj interface{}) error {
20 if err := req.ParseForm(); err != nil {
23 req.ParseMultipartForm(defaultMemory)
24 if err := mapForm(obj, req.Form); err != nil {
30 func (formPostBinding) Name() string {
31 return "form-urlencoded"
34 func (formPostBinding) Bind(req *http.Request, obj interface{}) error {
35 if err := req.ParseForm(); err != nil {
38 if err := mapForm(obj, req.PostForm); err != nil {
44 func (formMultipartBinding) Name() string {
45 return "multipart/form-data"
48 func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
49 if err := req.ParseMultipartForm(defaultMemory); err != nil {
52 if err := mapForm(obj, req.MultipartForm.Value); err != nil {