1
0
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:
Vishal Rana 2015-10-21 15:11:01 -07:00
parent a507447135
commit 143f563734
2 changed files with 2 additions and 3 deletions

View File

@ -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)
}

View File

@ -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)