I would like to have access to the matched pattern in the handler
In my use case I would like to know which pattern was matched. Locally I extended the Handler type to also pass the pattern and I tweaked node to have a pattern field that contains the pattern to match.
Is this something that you would find useful to add? I would be happy to issue a PR if so.
I can see how that would be useful. I have been working on changing the Handle type over to use the standard http handler, since Go 1.7 added contexts to the stdlib. That way we could more easily integrate with other packages as well as drop our custom handler altogether. That being said, do you think there is another way we could expose that info without having to have the customer handler?
I am a newbie to Go though it reminds me of my C days and I love it!! I am not sure other inherent ways that may exist to provide such context in a Go way. One approach that would work is to provide a reverse lookup mechanism. If I can pass the URI received to a lookup function to get the matching route that would be sufficient to my needs.
That is one of things that drew me to Go as well (that it was so similar to C). I think the reverse lookup would work, but might be cumbersome for the user of the API. What do you think if we just enabled a boolean on the router (much like the logging works today) to add the route if the user wants into the request of the context each time. That way it we can keep the default http handlers and still have a way to pull the pattern it was matched on?
I had to do a little reading and search for context. Yes that seems like a much more convenient approach.