From f839210454cd70807bd163b1c6880eb7c76ae6c3 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Tue, 6 Oct 2015 11:04:36 -0700 Subject: [PATCH] Getting echo reference from the node Signed-off-by: Vishal Rana --- echo.go | 5 +---- router.go | 11 +++++++++-- website/static/styles/echo.css | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/echo.go b/echo.go index 7bb1c5f8..b7c71736 100644 --- a/echo.go +++ b/echo.go @@ -463,10 +463,7 @@ func (e *Echo) Routes() []Route { // ServeHTTP implements `http.Handler` interface, which serves HTTP requests. func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) { c := e.pool.Get().(*Context) - h, echo := e.router.Find(r.Method, r.URL.Path, c) - if echo != nil { - e = echo - } + h, e := e.router.Find(r.Method, r.URL.Path, c) c.reset(r, w, e) // Chain middleware with handler in the end diff --git a/router.go b/router.go index aaf388cd..c0b2f65b 100644 --- a/router.go +++ b/router.go @@ -261,6 +261,7 @@ func (n *node) findHandler(method string) HandlerFunc { func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo) { h = notFoundHandler + e = r.echo cn := r.tree // Current node as root // Strip trailing slash @@ -369,17 +370,23 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo Found: ctx.pnames = cn.pnames h = cn.findHandler(method) + if cn.echo != nil { + e = cn.echo + } if h == nil { h = methodNotAllowedHandler - // Look up for match-any, might have an empty value for *, e.g. + // Dig further for match-any, might have an empty value for *, e.g. // serving a directory. Issue #207 if cn = cn.findChildWithType(mtype); cn == nil { return } +// println("here...") +// if cn.echo != nil { +// e = cn.echo +// } h = cn.findHandler(method) ctx.pvalues[len(cn.pnames)-1] = "" } - e = cn.echo return } diff --git a/website/static/styles/echo.css b/website/static/styles/echo.css index 5c21af2b..44fd0a41 100644 --- a/website/static/styles/echo.css +++ b/website/static/styles/echo.css @@ -20,8 +20,8 @@ code { color: #424242; font-size: .95em; font-family: Source Code Pro, Monaco, Menlo, Consolas, monospace; - border: 1px solid #BDBDBD; - border-radius: 4px; + border: 1px solid #E0E0E0; + border-radius: 2px; } a:link { text-decoration: none;