fix: use of requestStreamParams middleware in streaming routes#302
fix: use of requestStreamParams middleware in streaming routes#302Sergejpm wants to merge 1 commit intoakash-network:mainfrom
Conversation
WalkthroughThe router configuration for lease event and log streaming endpoints was refactored to consolidate middleware usage. Middleware previously applied via separate subrouters is now combined into a single subrouter for each endpoint, streamlining the setup for Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
gateway/rest/router.go (1)
175-185: Factor the repeated “stream sub-router” setup into a helper for DRYnessThe four-line pattern
mrouter = lrouter.NewRoute().Subrouter() mrouter.Use(requestStreamParams, requireEndpointScopeForLeaseID(scope))is duplicated for both the kubeevents and logs endpoints (and could appear again). Encapsulating it reduces duplication and keeps future middleware tweaks in one place:
+func leaseStreamSubrouter(parent *mux.Router, scope ajwt.PermissionScope) *mux.Router { + sr := parent.NewRoute().Subrouter() + sr.Use(requestStreamParams, requireEndpointScopeForLeaseID(scope)) + return sr +} ... - mrouter = lrouter.NewRoute().Subrouter() - mrouter.Use(requestStreamParams, requireEndpointScopeForLeaseID(ajwt.PermissionScopeEvents)) + mrouter = leaseStreamSubrouter(lrouter, ajwt.PermissionScopeEvents) ... - mrouter = lrouter.NewRoute().Subrouter() - mrouter.Use(requestStreamParams, requireEndpointScopeForLeaseID(ajwt.PermissionScopeLogs)) + mrouter = leaseStreamSubrouter(lrouter, ajwt.PermissionScopeLogs)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gateway/rest/router.go(1 hunks)
🔇 Additional comments (1)
gateway/rest/router.go (1)
175-176:requestStreamParamsnow wired-in – panic fixedAdding the middleware directly on the same sub-router as the permission check guarantees the query-parsing happens before the handler is hit, eliminating the nil-assertion panic that motivated the PR.
|
thanks, can you please: |
d269512 to
23e3ea9
Compare
23e3ea9 to
0a4af39
Compare
|
@Sergejpm Please, resolve merge conflicts and I will promote your PR to the main branch. |
resolves panic when retrieving provider logs or kube events