feat: introduce strongly-typed RequestContext#8497
Conversation
…xSet/Get functions
|
This PR introduces a strongly-typed Files Changed AnalysisThe changes introduce a new core component and integrate it into the request lifecycle:
Architecture & Impact Assessment
Request Context LifecyclesequenceDiagram
participant Client
participant Muxer as "proxy_muxer.go"
participant Rewriter as "DummyProxyHandler"
participant Sanitizer as "SanitizeProxyPaths"
Client->>+Muxer: HTTP Request
Muxer->>Muxer: Create & Inject RequestContext
Muxer->>+Rewriter: Process Request
Note over Rewriter: URL rewrite occurs
Rewriter->>Rewriter: rc.RewriteUrl(old, new)
Rewriter-->>-Muxer: Continue
Muxer->>+Sanitizer: Process Request
Sanitizer->>Sanitizer: rc.IsRewritten()? -> true
Note over Sanitizer: Skips path stripping
Sanitizer-->>-Muxer: Continue
Muxer-->>-Client: HTTP Response
Scope Discovery & Context ExpansionThis change establishes a new architectural pattern for state management. While the current scope is limited to URL rewriting, the introduction of The other keys defined in Metadata
Powered by Visor from Probelabs Last updated: 2026-07-20T10:28:30.767Z | Triggered by: pr_updated | Commit: 9c2fbe1 💡 TIP: You can chat with Visor using |
Security Issues (2)
Security Issues (2)
Performance Issues (1)
Powered by Visor from Probelabs Last updated: 2026-07-20T10:28:12.122Z | Triggered by: pr_updated | Commit: 9c2fbe1 💡 TIP: You can chat with Visor using |
|
SentinelOne CNS Hardcoded Secret Detector SentinelOne CNS is a cloud-agnostic, agentless CSPM & CWPP solution that continuously detects and prevents vulnerabilities that have the highest probability of being exploited in Azure, AWS, Google Cloud, and Kubernetes. |
Problem / Task
Currently, request state management in the Gateway relies heavily on
context.WithValuevia a family ofctxSet...andctxGet...functions. This approach lacks cohesion, requires type assertions, and makes it hard to track state. This PR introduces a strongly-typedRequestContextstruct to hold the mutable state of the request, starting with URL rewrite state.Changes
RequestContextstruct inctx/request_context.gowithRewriteUrl,Reset, andIsRewrittenmethods.GetRequestContextto work on a 'get or create' basis, injecting a newRequestContextinto the request context if it doesn't exist.RequestContextKeytoctx/ctx.go.DummyProxyHandler.ServeHTTPto userc.RewriteUrl.MCPVEMContinuationMiddlewareto userc.Reset.SanitizeProxyPathsto checkrc.IsRewritten().gateway/api_definition_test.go.Testing
strip=true but skipped because UrlRewritten is trueingateway/api_definition_test.go.go test ./gateway/... -run TestAPISpec_SanitizeProxyPathswhich passed.Requested by: U08QWRUM11Q
Slack thread: https://slack.com/archives/D0AF7G82CSV/p1784188011906799