From 3359eae3067d1f6dba4785ea0377796405a34429 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Tue, 16 May 2017 16:29:33 -0700 Subject: [PATCH] Add json tags to route struct Signed-off-by: Vishal Rana --- echo.go | 12 ++++++------ router.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/echo.go b/echo.go index 907f23c0..42c2bf83 100644 --- a/echo.go +++ b/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) } diff --git a/router.go b/router.go index 876fc5d8..33da20ed 100644 --- a/router.go +++ b/router.go @@ -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, } }