|
|
@ -10,7 +10,6 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
multipartFormData = "multipart/form-data"
|
|
|
|
|
|
|
|
formKey = "form"
|
|
|
|
formKey = "form"
|
|
|
|
pathKey = "path"
|
|
|
|
pathKey = "path"
|
|
|
|
emptyJson = "{}"
|
|
|
|
emptyJson = "{}"
|
|
|
@ -39,12 +38,12 @@ func Parse(r *http.Request, v interface{}) error {
|
|
|
|
|
|
|
|
|
|
|
|
// Parses the form request.
|
|
|
|
// Parses the form request.
|
|
|
|
func ParseForm(r *http.Request, v interface{}) error {
|
|
|
|
func ParseForm(r *http.Request, v interface{}) error {
|
|
|
|
if strings.Contains(r.Header.Get(ContentType), multipartFormData) {
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
if err := r.ParseMultipartForm(maxMemory); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if err := r.ParseForm(); err != nil {
|
|
|
|
if err := r.ParseMultipartForm(maxMemory); err != nil {
|
|
|
|
|
|
|
|
if err != http.ErrNotMultipart {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|