Fixes multipart integration
This commit is contained in:
parent
500d745123
commit
af8e099dfd
@ -9,13 +9,14 @@ import "net/http"
|
|||||||
type formBinding struct{}
|
type formBinding struct{}
|
||||||
|
|
||||||
func (_ formBinding) Name() string {
|
func (_ formBinding) Name() string {
|
||||||
return "query"
|
return "form"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ formBinding) Bind(req *http.Request, obj interface{}) error {
|
func (_ formBinding) Bind(req *http.Request, obj interface{}) error {
|
||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
req.ParseMultipartForm(32 << 10) // 32 MB
|
||||||
if err := mapForm(obj, req.Form); err != nil {
|
if err := mapForm(obj, req.Form); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -232,11 +232,13 @@ func (c *Context) query(key string) (string, bool) {
|
|||||||
func (c *Context) postForm(key string) (string, bool) {
|
func (c *Context) postForm(key string) (string, bool) {
|
||||||
req := c.Request
|
req := c.Request
|
||||||
req.ParseMultipartForm(32 << 20) // 32 MB
|
req.ParseMultipartForm(32 << 20) // 32 MB
|
||||||
if values, ok := req.PostForm[key]; ok && len(values) > 0 {
|
if values := req.PostForm[key]; len(values) > 0 {
|
||||||
return values[0], true
|
return values[0], true
|
||||||
}
|
}
|
||||||
if values, ok := req.MultipartForm.Value[key]; ok && len(values) > 0 {
|
if req.MultipartForm != nil && req.MultipartForm.File != nil {
|
||||||
return values[0], true
|
if values := req.MultipartForm.Value[key]; len(values) > 0 {
|
||||||
|
return values[0], true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "", false
|
return "", false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user