gin/binding/form_multipart.go
konjoot 48cfdd93d0 Restored multipart/form-data support
* restored support of multipart/form-data
* paths to the inner packages were changed, because using of absolute paths, like "github.com/gin-gonic/gin/binding", creates some difficulties for contributors,
  for example, when I make changes in the "binding" package in tests still used paсkage "binging" from github.com/gin-gonic/gin
* skipped failing tests
* wrote tests for multipart/form-data binding functionality
2015-05-26 13:56:43 +03:00

26 lines
593 B
Go

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package binding
import "net/http"
const MAX_MEMORY = 1 * 1024 * 1024
type multipartFormBinding struct{}
func (_ multipartFormBinding) Name() string {
return "multipart form"
}
func (_ multipartFormBinding) Bind(req *http.Request, obj interface{}) error {
if err := req.ParseMultipartForm(MAX_MEMORY); err != nil {
return err
}
if err := mapForm(obj, req.Form); err != nil {
return err
}
return Validate(obj)
}