When a request hits Gin, it would be great for instrumentation to have access to the original route string that was passed to register the handler that has been selected to handle the request.
Comment From: itsjamie
https://github.com/gin-gonic/gin/issues/584 was originally opened to support this. It appears that the original issue creator would like something similar to what I would like, and I'd be willing to take a crack at a PR, but figured I'd open an issue first to see if thoughts on whether it would be appreciated since the original issue was closed.
It would be great to see the selected Route available for introspection on the Context object. Right now, when one of our global middleware throws an exception, we can't track what the end path was going to be by handler.
Comment From: clutchski
I would like to see this as well. It's very good for instrumentation where you'd like to aggregate statistics by route (e.g. /user/:id
) and not by path. Is this on anybody's radar?
Comment From: jonaz
We would also need this. I did an ugly workarround in a middleware the mean time:
routes := p.parent.Routes()
url := ""
for _, r := range routes {
if r.Handler == c.HandlerName() {
url = r.Path
break
}
}
I guess its also affecting performance since every call is looping over all routes. But until this issue is resolved i think its the only way.