MCPcopy
hub / github.com/go-chi/chi / RoutePattern

Method RoutePattern

context.go:123–134  ·  view source on GitHub ↗

RoutePattern builds the routing pattern string for the particular request, at the particular point during routing. This means, the value will change throughout the execution of a request in a router. That is why it's advised to only use this value after calling the next handler. For example, func

()

Source from the content-addressed store, hash-verified

121// })
122// }
123func (x *Context) RoutePattern() string {
124 if x == nil {
125 return ""
126 }
127 routePattern := strings.Join(x.RoutePatterns, "")
128 routePattern = replaceWildcards(routePattern)
129 if routePattern != "/" {
130 routePattern = strings.TrimSuffix(routePattern, "//")
131 routePattern = strings.TrimSuffix(routePattern, "/")
132 }
133 return routePattern
134}
135
136// replaceWildcards takes a route pattern and replaces all occurrences of
137// "/*/" with "/". It iteratively runs until no wildcards remain to

Callers 3

TestRoutePatternFunction · 0.95
routeHTTPMethod · 0.80
FileServerFunction · 0.80

Calls 1

replaceWildcardsFunction · 0.85

Tested by 1

TestRoutePatternFunction · 0.76