From 4abcec5fbc19fc0fcb520988bfba5d8cfbe6c260 Mon Sep 17 00:00:00 2001 From: wgdzlh <13d1101@gmail.com> Date: Thu, 21 Jul 2022 11:37:52 +0800 Subject: [PATCH] fix: log the original path being redirected --- gin.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gin.go b/gin.go index f9324299..854fc0c9 100644 --- a/gin.go +++ b/gin.go @@ -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 { @@ -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