From 500d745123124fa6a8f8ffcae80fc5290307b15a Mon Sep 17 00:00:00 2001 From: Manu Mtz-Almeida Date: Tue, 26 May 2015 16:16:57 +0200 Subject: [PATCH] PostForm() handles multipart post --- context.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index ecacf945..4d03b8b5 100644 --- a/context.go +++ b/context.go @@ -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 }