chi icon indicating copy to clipboard operation
chi copied to clipboard

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

Open IDispose opened this issue 2 years ago • 2 comments

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?

IDispose avatar Dec 21 '22 13:12 IDispose

I need to do the same thing. I cannot see a workaround other than re-implementing FindRoute with the input of mux.Routes(). I'm happy to raise a PR for this if the maintainers are open to it.

insano10 avatar Jan 26 '23 12:01 insano10

Also looking for the same feature.

davidspiess avatar Feb 20 '23 18:02 davidspiess