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

fix: log the original path being redirected #3253

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions gin.go
Expand Up @@ -674,7 +674,7 @@ func redirectTrailingSlash(c *Context) {
if length := len(p); length > 1 && p[length-1] == '/' {
req.URL.Path = p[:length-1]
}
redirectRequest(c)
redirectRequest(c, p)
}

func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
Expand All @@ -683,15 +683,14 @@ func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {

if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(rPath), trailingSlash); ok {
req.URL.Path = bytesconv.BytesToString(fixedPath)
redirectRequest(c)
redirectRequest(c, rPath)
return true
}
return false
}

func redirectRequest(c *Context) {
func redirectRequest(c *Context, rPath string) {
req := c.Request
rPath := req.URL.Path
rURL := req.URL.String()

code := http.StatusMovedPermanently // Permanent redirect, request with GET method
Expand Down