1
0
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:
Vishal Rana 2017-05-16 16:29:33 -07:00
parent cb9255e775
commit 3359eae306
2 changed files with 8 additions and 8 deletions

12
echo.go
View File

@ -86,9 +86,9 @@ type (
// Route contains a handler and information for matching against requests. // Route contains a handler and information for matching against requests.
Route struct { Route struct {
Method string Method string `json:"method"`
Path string Path string `json:"path"`
Handler string Handler string `json:"handler"`
} }
// HTTPError represents an error that occurred while handling a request. // 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) return h(c)
}) })
r := Route{ r := &Route{
Method: method, Method: method,
Path: path, Path: path,
Handler: name, Handler: name,
@ -502,8 +502,8 @@ 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 {
routes := []Route{} routes := []*Route{}
for _, v := range e.router.routes { for _, v := range e.router.routes {
routes = append(routes, v) routes = append(routes, v)
} }

View File

@ -7,7 +7,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 map[string]Route routes map[string]*Route
echo *Echo echo *Echo
} }
node struct { node struct {
@ -47,7 +47,7 @@ func NewRouter(e *Echo) *Router {
tree: &node{ tree: &node{
methodHandler: new(methodHandler), methodHandler: new(methodHandler),
}, },
routes: map[string]Route{}, routes: map[string]*Route{},
echo: e, echo: e,
} }
} }