Skip to content

Commit 536f5e7

Browse files
committed
ip check more reliable
1 parent 2fca76f commit 536f5e7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

middleware/request_logger_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ func TestRequestLogger_allFields(t *testing.T) {
286286
req.Header.Set("User-Agent", "curl/7.68.0")
287287
req.Header.Set(echo.HeaderContentLength, strconv.Itoa(int(reader.Size())))
288288
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationForm)
289+
req.Header.Set(echo.HeaderXRealIP, "8.8.8.8")
289290

290291
rec := httptest.NewRecorder()
291292
c := e.NewContext(req, rec)
@@ -297,7 +298,7 @@ func TestRequestLogger_allFields(t *testing.T) {
297298
assert.NoError(t, err)
298299
assert.Equal(t, 10*time.Second, expect.Latency)
299300
assert.Equal(t, "HTTP/1.1", expect.Protocol)
300-
assert.Equal(t, "192.0.2.1", expect.RemoteIP)
301+
assert.Equal(t, "8.8.8.8", expect.RemoteIP)
301302
assert.Equal(t, "example.com", expect.Host)
302303
assert.Equal(t, http.MethodPost, expect.Method)
303304
assert.Equal(t, "/test?lang=en&checked=1&checked=2", expect.URI)

0 commit comments

Comments
 (0)