Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce HandlerID cardinality by default in gin middleware #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fallback to Request.URL.Path if the route does not exist
  • Loading branch information
Alex Arwine committed Nov 18, 2021
commit 57e61a288f99b5e675d6b08c13cb2b2d2b76ad71
8 changes: 7 additions & 1 deletion middleware/gin/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ func (r *reporter) Method() string { return r.c.Request.Method }

func (r *reporter) Context() context.Context { return r.c.Request.Context() }

func (r *reporter) URLPath() string { return r.c.FullPath() }
func (r *reporter) URLPath() string {
urlPath := r.c.FullPath()
if urlPath == "" {
return r.c.Request.URL.Path
}
return urlPath
}

func (r *reporter) StatusCode() int { return r.c.Writer.Status() }

Expand Down