From 09c308b555625ae7dec7e9d2fea0ed65375dd9c7 Mon Sep 17 00:00:00 2001 From: Thomas Schaffer Date: Wed, 7 Mar 2018 09:09:58 +0100 Subject: [PATCH] Expose HandlerFunc in RouteInfos --- gin.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gin.go b/gin.go index 4205eff0..4517d70f 100644 --- a/gin.go +++ b/gin.go @@ -38,9 +38,10 @@ func (c HandlersChain) Last() HandlerFunc { } type RouteInfo struct { - Method string - Path string - Handler string + Method string + Path string + Handler string + HandlerFunc HandlerFunc } type RoutesInfo []RouteInfo @@ -264,10 +265,12 @@ func (engine *Engine) Routes() (routes RoutesInfo) { func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo { path += root.path if len(root.handlers) > 0 { + handlerFunc := root.handlers.Last() routes = append(routes, RouteInfo{ - Method: method, - Path: path, - Handler: nameOfFunction(root.handlers.Last()), + Method: method, + Path: path, + Handler: nameOfFunction(handlerFunc), + HandlerFunc: handlerFunc, }) } for _, child := range root.children {