Skip to content

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

@gustavoquintana-peya

Description

@gustavoquintana-peya

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions