Skip to content

Commit

Permalink
Expose HandlerFunc in RouteInfos (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
loopfz authored and thinkerou committed Oct 23, 2018
1 parent dbc330b commit c65e5ef
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ func (c HandlersChain) Last() HandlerFunc {

// RouteInfo represents a request route's specification which contains method and path and its handler.
type RouteInfo struct {
Method string
Path string
Handler string
Method string
Path string
Handler string
HandlerFunc HandlerFunc
}

// RoutesInfo defines a RouteInfo array.
Expand Down Expand Up @@ -266,10 +267,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 {
Expand Down

0 comments on commit c65e5ef

Please sign in to comment.