From 647de05e9acb3d9071ea1663cce08f9a286bb048 Mon Sep 17 00:00:00 2001 From: Long Le Date: Tue, 14 Jan 2025 06:55:48 -0500 Subject: [PATCH] removed request uri template option --- gateway/middleware.go | 2 -- internal/httputil/accesslog/access_log.go | 9 --------- internal/httputil/accesslog/access_log_test.go | 5 +---- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/gateway/middleware.go b/gateway/middleware.go index 5122c716e6d..08456b8adc1 100644 --- a/gateway/middleware.go +++ b/gateway/middleware.go @@ -456,8 +456,6 @@ func (t *BaseMiddleware) recordAccessLog(req *http.Request, resp *http.Response, accessLog.WithLatency(latency) case "request": accessLog.WithRequest(req) - case "requesturi": - accessLog.WithRequestURI(req) case "response": accessLog.WithResponse(resp) case "upstream": diff --git a/internal/httputil/accesslog/access_log.go b/internal/httputil/accesslog/access_log.go index 4ee4e307a1f..19643b64560 100644 --- a/internal/httputil/accesslog/access_log.go +++ b/internal/httputil/accesslog/access_log.go @@ -71,15 +71,6 @@ func (a *Record) WithRequest(req *http.Request) *Record { return a } -// WithRequestURI sets the request URI of the Record. May contain sensitive data such as -// query parameters etc. -func (a *Record) WithRequestURI(req *http.Request) *Record { - if req != nil { - a.fields["request_uri"] = req.RequestURI - } - return a -} - // WithResponse sets the response data of the Record. func (a *Record) WithResponse(resp *http.Response) *Record { if resp != nil { diff --git a/internal/httputil/accesslog/access_log_test.go b/internal/httputil/accesslog/access_log_test.go index cf0282d9cd7..34ce3882883 100644 --- a/internal/httputil/accesslog/access_log_test.go +++ b/internal/httputil/accesslog/access_log_test.go @@ -69,7 +69,7 @@ func TestNewRecordField(t *testing.T) { StatusCode: http.StatusOK, } - record := NewRecord().WithClientIP(req).WithLatency(latency).WithRequest(req).WithRequestURI(req).WithResponse(resp).WithUpstreamAddress(req).WithUpstreamURI(req).Fields() + record := NewRecord().WithClientIP(req).WithLatency(latency).WithRequest(req).WithResponse(resp).WithUpstreamAddress(req).WithUpstreamURI(req).Fields() assert.Equal(t, "access-log", record["prefix"]) @@ -87,9 +87,6 @@ func TestNewRecordField(t *testing.T) { assert.Equal(t, "HTTP/1.1", record["protocol"]) assert.Equal(t, "user-agent", record["user_agent"]) - // WithRequest URI - assert.Equal(t, "http://example.com/path?userid=1", record["request_uri"]) - // WithResponse assert.Equal(t, http.StatusOK, record["status_code"])