Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path"
"regexp"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -68,10 +69,11 @@ 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
HandlerFunc HandlerFunc
Method string
Path string
Handler string
HandlerFunc HandlerFunc
HandlersChain HandlersChain
}

// RoutesInfo defines a RouteInfo slice.
Expand Down Expand Up @@ -389,10 +391,11 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo {
if len(root.handlers) > 0 {
handlerFunc := root.handlers.Last()
routes = append(routes, RouteInfo{
Method: method,
Path: path,
Handler: nameOfFunction(handlerFunc),
HandlerFunc: handlerFunc,
Method: method,
Path: path,
Handler: nameOfFunction(handlerFunc),
HandlerFunc: handlerFunc,
HandlersChain: slices.Clone(root.handlers),
})
}
for _, child := range root.children {
Expand Down