feat: Add the feature flag middleware to the websocket server
What does this merge request do and why?
Translate the FeatureFlagInterceptor logic from the gRPC server into a FastAPI middleware format
AI generated summary:
This change extends the existing feature flag functionality to support WebSocket connections in addition to gRPC. The code now includes a new
FeatureFlagMiddlewareclass that works with WebSockets, similar to how the existingFeatureFlagInterceptorworks with gRPC.The implementation extracts common feature flag processing logic into a shared
_set_feature_flag_contextfunction that both the interceptor and middleware can use. This function handles extracting feature flags from request headers and filtering out disallowed flags based on the GitLab realm.The WebSocket server configuration has been updated to include this new middleware in its chain. Comprehensive tests have been added to verify the middleware works correctly in various scenarios.
How to set up and validate locally
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Relates to #968 (closed)