mirror of
https://github.com/labstack/echo.git
synced 2025-01-12 01:22:21 +02:00
Moved code around
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
a507447135
commit
143f563734
@ -15,13 +15,12 @@ func Logger() echo.MiddlewareFunc {
|
||||
req := c.Request()
|
||||
res := c.Response()
|
||||
|
||||
var remoteAddr string
|
||||
remoteAddr := req.RemoteAddr
|
||||
if ip := req.Header.Get(echo.XRealIP); ip != "" {
|
||||
remoteAddr = ip
|
||||
} else if ip = req.Header.Get(echo.XForwardedFor); ip != "" {
|
||||
remoteAddr = ip
|
||||
} else {
|
||||
remoteAddr = req.RemoteAddr
|
||||
remoteAddr, _, _ = net.SplitHostPort(remoteAddr)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func TestLogger(t *testing.T) {
|
||||
Logger()(h)(c)
|
||||
}
|
||||
|
||||
func TestLogger_IPAddress(t *testing.T) {
|
||||
func TestLoggerIPAddress(t *testing.T) {
|
||||
buf := &bytes.Buffer{}
|
||||
log.SetOutput(buf)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user