feat: add option to log every request with path and IP

This commit is contained in:
crapStone 2025-06-12 22:57:04 +02:00 committed by crapStone
parent 2b2f280bc3
commit 023ea17492
5 changed files with 30 additions and 0 deletions

View file

@ -140,6 +140,8 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
Port: 8080,
HttpPort: 80,
HttpServerEnabled: false,
UseProxyProtocol: false,
LogEveryRequest: false,
MainDomain: "original",
RawDomain: "original",
PagesBranches: []string{"original"},
@ -180,6 +182,8 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
Port: 8443,
HttpPort: 443,
HttpServerEnabled: true,
UseProxyProtocol: true,
LogEveryRequest: true,
MainDomain: "changed",
RawDomain: "changed",
PagesBranches: []string{"changed"},
@ -227,6 +231,8 @@ func TestMergeConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *testing.T
"--port", "8443",
"--http-port", "443",
"--enable-http-server",
"--use-proxy-protocol",
"--log-every-request",
// Forge
"--forge-root", "changed",
"--forge-api-token", "changed",
@ -277,6 +283,8 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
Port: 8080,
HttpPort: 80,
HttpServerEnabled: false,
UseProxyProtocol: false,
LogEveryRequest: false,
MainDomain: "original",
RawDomain: "original",
AllowedCorsDomains: []string{"original"},
@ -290,6 +298,8 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
Port: 8443,
HttpPort: 443,
HttpServerEnabled: true,
UseProxyProtocol: true,
LogEveryRequest: true,
MainDomain: "changed",
RawDomain: "changed",
AllowedCorsDomains: fixArrayFromCtx(ctx, "allowed-cors-domains", []string{"changed"}),
@ -309,6 +319,8 @@ func TestMergeServerConfigShouldReplaceAllExistingValuesGivenAllArgsExist(t *tes
"--port", "8443",
"--http-port", "443",
"--enable-http-server",
"--use-proxy-protocol",
"--log-every-request",
},
)
}
@ -329,6 +341,8 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
{args: []string{"--pages-branch", "changed"}, callback: func(sc *ServerConfig) { sc.PagesBranches = []string{"changed"} }},
{args: []string{"--allowed-cors-domains", "changed"}, callback: func(sc *ServerConfig) { sc.AllowedCorsDomains = []string{"changed"} }},
{args: []string{"--blacklisted-paths", "changed"}, callback: func(sc *ServerConfig) { sc.BlacklistedPaths = []string{"changed"} }},
{args: []string{"--use-proxy-protocol"}, callback: func(sc *ServerConfig) { sc.UseProxyProtocol = true }},
{args: []string{"--log-every-request"}, callback: func(sc *ServerConfig) { sc.LogEveryRequest = true }},
}
for _, pair := range testValuePairs {
@ -345,6 +359,8 @@ func TestMergeServerConfigShouldReplaceOnlyOneValueExistingValueGivenOnlyOneArgE
PagesBranches: []string{"original"},
AllowedCorsDomains: []string{"original"},
BlacklistedPaths: []string{"original"},
UseProxyProtocol: false,
LogEveryRequest: false,
}
expectedConfig := cfg