Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chi.RouteContext(r.Context()).RoutePattern() returns "" #846

Closed
gustavoquintana-peya opened this issue Sep 7, 2023 · 0 comments · Fixed by #847
Closed

chi.RouteContext(r.Context()).RoutePattern() returns "" #846

gustavoquintana-peya opened this issue Sep 7, 2023 · 0 comments · Fixed by #847

Comments

@gustavoquintana-peya
Copy link

with a route like this

r := chi.NewRouter()
r.Get("/", handler)

when a request to localhost:8080/ is received, the method chi.RouteContext(r.Context()).RoutePattern() return ""

I think the expected value is /

maybe this can help

func (x *Context) RoutePattern() string {
	routePattern := strings.Join(x.RoutePatterns, "")
	routePattern = replaceWildcards(routePattern)
	routePattern = strings.TrimSuffix(routePattern, "//")
	if len(routePattern) > 1 {
		routePattern = strings.TrimSuffix(routePattern, "/")
	}
	return routePattern
}
AthfanFasee added a commit to AthfanFasee/chi that referenced this issue Sep 11, 2023
@AthfanFasee AthfanFasee mentioned this issue Sep 11, 2023
pkieltyka pushed a commit that referenced this issue Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant