feat(handler/reverseproxy): filter relevant access requests

This commit is contained in:
Trong Huu Nguyen
2023-12-20 15:41:29 +01:00
parent 41f4354ce4
commit 40497da1b9

View File

@@ -155,7 +155,7 @@ func (rp *ReverseProxy) Handler(src ReverseProxySource, w http.ResponseWriter, r
if isAuthenticated {
ctx = mw.WithAccessToken(ctx, accessToken)
if rp.EnableAccessLogs {
if rp.EnableAccessLogs && isRelevantAccessLog(r) {
logger.Info("default: authenticated request")
}
}
@@ -217,6 +217,16 @@ func handleAutologin(src ReverseProxySource, w http.ResponseWriter, r *http.Requ
}
}
func isRelevantAccessLog(r *http.Request) bool {
if r.Method == http.MethodGet {
// only log GET requests that are navigation requests
return isNavigationRequest(r)
}
// all other methods are relevant
return true
}
func isNavigationRequest(r *http.Request) bool {
// we assume that navigation requests are always GET requests
if r.Method != http.MethodGet {