1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-17 01:43:02 +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 { func upload(c *echo.Context) error {
req := c.Request() req := c.Request()
req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
// req.ParseMultipartForm(16 << 20) // Max memory 16 MiB
// Read form fields // Read form fields
name := c.Form("name") 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 // Strip trailing slash
if r.echo.stripTrailingSlash { if r.echo.stripTrailingSlash {
l := len(path) l := len(path)-1
if path != "/" && path[l-1] == '/' { // Issue #218 if path != "/" && path[l] == '/' { // Issue #218
path = path[:l-1] 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 // Search order static > param > match-any
for { for {
if search == "" { if search == "" {
if cn.handler != nil { goto Found
// Found
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
}
return
} }
pl := 0 // Prefix length 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 { if cn.handler == nil {
// Look up for match-any, might have an empty value for *, e.g. // Look up for match-any, might have an empty value for *, e.g.
// serving a directory. Issue #207 // serving a directory. Issue #207
cn = cn.findChildWithType(mtype) if cn = cn.findChildWithType(mtype); cn == nil {
return
}
ctx.pvalues[len(cn.pnames)-1] = "" ctx.pvalues[len(cn.pnames)-1] = ""
} }
continue goto Found
} }
// Static node // Static node
@ -394,13 +390,18 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
if c != nil { if c != nil {
cn = c cn = c
ctx.pvalues[len(cn.pnames)-1] = search ctx.pvalues[len(cn.pnames)-1] = search
search = "" // End search goto Found
continue
} }
// Not found // Not found
return return
} }
Found:
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
return
} }
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {

View File

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