Explorar o código

Captures the path before any middleware modifies it

Manu Mtz-Almeida %!s(int64=10) %!d(string=hai) anos
pai
achega
67f8f6bb69
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      logger.go

+ 2 - 1
logger.go

@@ -46,6 +46,7 @@ func LoggerWithFile(out io.Writer) HandlerFunc {
 	return func(c *Context) {
 		// Start timer
 		start := time.Now()
+		path := c.Request.URL.Path
 
 		// Process request
 		c.Next()
@@ -67,7 +68,7 @@ func LoggerWithFile(out io.Writer) HandlerFunc {
 			latency,
 			clientIP,
 			methodColor, reset, method,
-			c.Request.URL.Path,
+			path,
 			comment,
 		)
 	}