mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Add json tags to route struct
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
cb9255e775
commit
3359eae306
12
echo.go
12
echo.go
@ -86,9 +86,9 @@ type (
|
||||
|
||||
// Route contains a handler and information for matching against requests.
|
||||
Route struct {
|
||||
Method string
|
||||
Path string
|
||||
Handler string
|
||||
Method string `json:"method"`
|
||||
Path string `json:"path"`
|
||||
Handler string `json:"handler"`
|
||||
}
|
||||
|
||||
// HTTPError represents an error that occurred while handling a request.
|
||||
@ -456,7 +456,7 @@ func (e *Echo) add(method, path string, handler HandlerFunc, middleware ...Middl
|
||||
}
|
||||
return h(c)
|
||||
})
|
||||
r := Route{
|
||||
r := &Route{
|
||||
Method: method,
|
||||
Path: path,
|
||||
Handler: name,
|
||||
@ -502,8 +502,8 @@ func (e *Echo) URL(h HandlerFunc, params ...interface{}) string {
|
||||
}
|
||||
|
||||
// Routes returns the registered routes.
|
||||
func (e *Echo) Routes() []Route {
|
||||
routes := []Route{}
|
||||
func (e *Echo) Routes() []*Route {
|
||||
routes := []*Route{}
|
||||
for _, v := range e.router.routes {
|
||||
routes = append(routes, v)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ type (
|
||||
// request matching and URL path parameter parsing.
|
||||
Router struct {
|
||||
tree *node
|
||||
routes map[string]Route
|
||||
routes map[string]*Route
|
||||
echo *Echo
|
||||
}
|
||||
node struct {
|
||||
@ -47,7 +47,7 @@ func NewRouter(e *Echo) *Router {
|
||||
tree: &node{
|
||||
methodHandler: new(methodHandler),
|
||||
},
|
||||
routes: map[string]Route{},
|
||||
routes: map[string]*Route{},
|
||||
echo: e,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user