Skip to content

Commit

Permalink
removed request uri template option
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Le authored and Long Le committed Jan 14, 2025
1 parent 1ce6d4d commit 647de05
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
2 changes: 0 additions & 2 deletions gateway/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
9 changes: 0 additions & 9 deletions internal/httputil/accesslog/access_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions internal/httputil/accesslog/access_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -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"])

Expand Down

0 comments on commit 647de05

Please sign in to comment.