replaceRemoteAddr sets the req.RemoteAddr for request
(req *http.Request, ip string)
| 252 | |
| 253 | // replaceRemoteAddr sets the req.RemoteAddr for request |
| 254 | func replaceRemoteAddr(req *http.Request, ip string) { |
| 255 | _, port, err := net.SplitHostPort(req.RemoteAddr) |
| 256 | if err != nil { |
| 257 | port = "80" |
| 258 | } |
| 259 | |
| 260 | req.RemoteAddr = net.JoinHostPort(strings.TrimSpace(ip), port) |
| 261 | } |
| 262 | |
| 263 | // Silent sets Silent flag which suppresses logs to true. We do not need to log |
| 264 | // requests like /health of /favicon.ico |