1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-03 22:59:09 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2015-07-27 08:43:11 -07:00
parent 1ae7ef40e0
commit d077efe91a
4 changed files with 20 additions and 29 deletions

View File

@@ -39,10 +39,8 @@ const (
mtype
)
func NewRouter(e *Echo) (r *Router) {
r = &Router{
routes: []Route{},
echo: e,
func NewRouter(e *Echo) *Router {
return &Router{
connectTree: new(node),
deleteTree: new(node),
getTree: new(node),
@@ -52,8 +50,9 @@ func NewRouter(e *Echo) (r *Router) {
postTree: new(node),
putTree: new(node),
traceTree: new(node),
routes: []Route{},
echo: e,
}
return
}
func (r *Router) Add(method, path string, h HandlerFunc, e *Echo) {
@@ -307,10 +306,12 @@ func (r *Router) Find(method, path string, ctx *Context) (h HandlerFunc, e *Echo
// Search order static > param > match-any
for {
if search == "" {
// Found
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
if cn.handler != nil {
// Found
ctx.pnames = cn.pnames
h = cn.handler
e = cn.echo
}
return
}