1
0
mirror of https://github.com/labstack/echo.git synced 2024-11-28 08:38:39 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-09-24 14:14:01 -07:00
parent d079d36162
commit 51a1ef432c
3 changed files with 17 additions and 18 deletions

View File

@ -12,8 +12,7 @@ import (
func upload(c *echo.Context) error {
req := c.Request()
// req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
// Read form fields
name := c.Form("name")

View File

@ -285,9 +285,9 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
// Strip trailing slash
if r.echo.stripTrailingSlash {
l := len(path)
if path != "/" && path[l-1] == '/' { // Issue #218
path = path[:l-1]
l := len(path)-1
if path != "/" && path[l] == '/' { // Issue #218
path = path[:l]
}
}
@ -303,13 +303,7 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
// Search order static > param > match-any
for {
if search == "" {
if cn.handler != nil {
// Found
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
}
return
goto Found
}
pl := 0 // Prefix length
@ -348,10 +342,12 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
if cn.handler == nil {
// Look up for match-any, might have an empty value for *, e.g.
// serving a directory. Issue #207
cn = cn.findChildWithType(mtype)
if cn = cn.findChildWithType(mtype); cn == nil {
return
}
ctx.pvalues[len(cn.pnames)-1] = ""
}
continue
goto Found
}
// Static node
@ -394,13 +390,18 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
if c != nil {
cn = c
ctx.pvalues[len(cn.pnames)-1] = search
search = "" // End search
continue
goto Found
}
// Not found
return
}
Found:
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
return
}
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {

View File

@ -25,8 +25,7 @@ import (
func upload(c *echo.Context) error {
req := c.Request()
// req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
// Read form fields
name := c.Form("name")