go-chi / go-chi/chi

Expose FindRoute on Mux to enable access to it in custom middleware

Open
#774 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
22.8k
Forks
1.2k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

We are building a custom middleware which needs to know the route that matched the current request path. Unfortunately, the only available option `Match` just returns a yay or nay. Since this method has access to the actual route that matches, can we add a `FindRoute` on `Mux` that will delegate the actual work to `tree.FindRoute` ?

Is there an alternate way to determine the route that matches the current http request path in a custom middleware?

Contributor guide

Open the contributing guide

Research direction

Start by comparing the existing Mux.Match entry point with the tree.FindRoute method mentioned in the issue, then trace how custom middleware accesses the current request path. Done means exposing Mux.FindRoute as a delegation to tree.FindRoute and confirming that middleware can obtain the matching route.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.