mirror of
https://github.com/labstack/echo.git
synced 2025-07-15 01:34:53 +02:00
9
echo.go
9
echo.go
@ -471,7 +471,8 @@ func (e *Echo) add(method, path string, handler HandlerFunc, middleware ...Middl
|
|||||||
Path: path,
|
Path: path,
|
||||||
Handler: name,
|
Handler: name,
|
||||||
}
|
}
|
||||||
e.router.routes = append(e.router.routes, r)
|
e.router.routes[method+path] = r
|
||||||
|
// e.router.routes = append(e.router.routes, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group creates a new router group with prefix and optional group-level middleware.
|
// Group creates a new router group with prefix and optional group-level middleware.
|
||||||
@ -513,7 +514,11 @@ func (e *Echo) URL(h HandlerFunc, params ...interface{}) string {
|
|||||||
|
|
||||||
// Routes returns the registered routes.
|
// Routes returns the registered routes.
|
||||||
func (e *Echo) Routes() []Route {
|
func (e *Echo) Routes() []Route {
|
||||||
return e.router.routes
|
routes := []Route{}
|
||||||
|
for _, v := range e.router.routes {
|
||||||
|
routes = append(routes, v)
|
||||||
|
}
|
||||||
|
return routes
|
||||||
}
|
}
|
||||||
|
|
||||||
// AcquireContext returns an empty `Context` instance from the pool.
|
// AcquireContext returns an empty `Context` instance from the pool.
|
||||||
|
@ -5,7 +5,7 @@ type (
|
|||||||
// request matching and URL path parameter parsing.
|
// request matching and URL path parameter parsing.
|
||||||
Router struct {
|
Router struct {
|
||||||
tree *node
|
tree *node
|
||||||
routes []Route
|
routes map[string]Route
|
||||||
echo *Echo
|
echo *Echo
|
||||||
}
|
}
|
||||||
node struct {
|
node struct {
|
||||||
@ -45,7 +45,7 @@ func NewRouter(e *Echo) *Router {
|
|||||||
tree: &node{
|
tree: &node{
|
||||||
methodHandler: new(methodHandler),
|
methodHandler: new(methodHandler),
|
||||||
},
|
},
|
||||||
routes: []Route{},
|
routes: make(map[string]Route),
|
||||||
echo: e,
|
echo: e,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user