mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-20 05:10:52 +08:00
- Introduced unit tests for request logging middleware to enhance coverage. - Added WebSocket-based Codex executor to support Responses API upgrade. - Updated middleware logic to selectively capture request bodies for memory efficiency. - Enhanced Codex configuration handling with new WebSocket attributes.
24 lines
674 B
Go
24 lines
674 B
Go
package executor
|
|
|
|
import "context"
|
|
|
|
type downstreamWebsocketContextKey struct{}
|
|
|
|
// WithDownstreamWebsocket marks the current request as coming from a downstream websocket connection.
|
|
func WithDownstreamWebsocket(ctx context.Context) context.Context {
|
|
if ctx == nil {
|
|
ctx = context.Background()
|
|
}
|
|
return context.WithValue(ctx, downstreamWebsocketContextKey{}, true)
|
|
}
|
|
|
|
// DownstreamWebsocket reports whether the current request originates from a downstream websocket connection.
|
|
func DownstreamWebsocket(ctx context.Context) bool {
|
|
if ctx == nil {
|
|
return false
|
|
}
|
|
raw := ctx.Value(downstreamWebsocketContextKey{})
|
|
enabled, ok := raw.(bool)
|
|
return ok && enabled
|
|
}
|