mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
fix: log the original path being redirected
This commit is contained in:
parent
b57163a0e4
commit
4abcec5fbc
7
gin.go
7
gin.go
@ -674,7 +674,7 @@ func redirectTrailingSlash(c *Context) {
|
|||||||
if length := len(p); length > 1 && p[length-1] == '/' {
|
if length := len(p); length > 1 && p[length-1] == '/' {
|
||||||
req.URL.Path = p[:length-1]
|
req.URL.Path = p[:length-1]
|
||||||
}
|
}
|
||||||
redirectRequest(c)
|
redirectRequest(c, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
|
func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
|
||||||
@ -683,15 +683,14 @@ func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
|
|||||||
|
|
||||||
if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(rPath), trailingSlash); ok {
|
if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(rPath), trailingSlash); ok {
|
||||||
req.URL.Path = bytesconv.BytesToString(fixedPath)
|
req.URL.Path = bytesconv.BytesToString(fixedPath)
|
||||||
redirectRequest(c)
|
redirectRequest(c, rPath)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func redirectRequest(c *Context) {
|
func redirectRequest(c *Context, rPath string) {
|
||||||
req := c.Request
|
req := c.Request
|
||||||
rPath := req.URL.Path
|
|
||||||
rURL := req.URL.String()
|
rURL := req.URL.String()
|
||||||
|
|
||||||
code := http.StatusMovedPermanently // Permanent redirect, request with GET method
|
code := http.StatusMovedPermanently // Permanent redirect, request with GET method
|
||||||
|
Loading…
x
Reference in New Issue
Block a user