mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 13:02:14 +08:00
* 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
26 lines
593 B
Go
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)
|
|
}
|