PostForm() handles multipart post

This commit is contained in:
Manu Mtz-Almeida 2015-05-26 16:16:57 +02:00
parent 195ea88a28
commit 500d745123
1 changed files with 6 additions and 3 deletions

View File

@ -30,8 +30,6 @@ const (
const AbortIndex = math.MaxInt8 / 2
var _ context.Context = &Context{}
// Param is a single URL parameter, consisting of a key and a value.
type Param struct {
Key string
@ -76,6 +74,8 @@ type Context struct {
Accepted []string
}
var _ context.Context = &Context{}
/************************************/
/********** CONTEXT CREATION ********/
/************************************/
@ -231,10 +231,13 @@ func (c *Context) query(key string) (string, bool) {
func (c *Context) postForm(key string) (string, bool) {
req := c.Request
req.ParseForm()
req.ParseMultipartForm(32 << 20) // 32 MB
if values, ok := req.PostForm[key]; ok && len(values) > 0 {
return values[0], true
}
if values, ok := req.MultipartForm.Value[key]; ok && len(values) > 0 {
return values[0], true
}
return "", false
}