mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-10 02:16:49 +08:00
feat(middleware): support logging for Codex response websockets
- Updated request logging middleware to include `/backend-api/codex/responses` as a valid websocket path. - Enhanced unit tests to cover new websocket path scenarios.
This commit is contained in:
@@ -114,7 +114,7 @@ func isResponsesWebsocketUpgrade(req *http.Request) bool {
|
||||
if req == nil || req.URL == nil {
|
||||
return false
|
||||
}
|
||||
if req.URL.Path != "/v1/responses" {
|
||||
if req.URL.Path != "/v1/responses" && req.URL.Path != "/backend-api/codex/responses" {
|
||||
return false
|
||||
}
|
||||
return strings.EqualFold(strings.TrimSpace(req.Header.Get("Upgrade")), "websocket")
|
||||
|
||||
@@ -52,6 +52,15 @@ func TestShouldSkipMethodForRequestLogging(t *testing.T) {
|
||||
},
|
||||
skip: false,
|
||||
},
|
||||
{
|
||||
name: "codex responses websocket upgrade should not skip",
|
||||
req: &http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: &url.URL{Path: "/backend-api/codex/responses"},
|
||||
Header: http.Header{"Upgrade": []string{"websocket"}},
|
||||
},
|
||||
skip: false,
|
||||
},
|
||||
{
|
||||
name: "responses get without upgrade should skip",
|
||||
req: &http.Request{
|
||||
@@ -151,7 +160,7 @@ func TestAttachRequestLogSourcesUsesLoggerLogsDir(t *testing.T) {
|
||||
logger := logging.NewFileRequestLogger(true, logsDir, "", 0)
|
||||
recorder := httptest.NewRecorder()
|
||||
c, _ := gin.CreateTestContext(recorder)
|
||||
c.Request = httptest.NewRequest(http.MethodGet, "/v1/responses", nil)
|
||||
c.Request = httptest.NewRequest(http.MethodGet, "/backend-api/codex/responses", nil)
|
||||
c.Request.Header.Set("Upgrade", "websocket")
|
||||
|
||||
attachRequestLogSources(c, logger, true)
|
||||
|
||||
Reference in New Issue
Block a user