Repository navigation
refactor: Rename withResponse to respond (matches connect/hijack) - #134
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughRenames the context API method from withResponse(...) to respond(...) across the core context types and all call sites, including handlers, middleware, server code, example, and tests. Public signatures in lib/src/adapter/context.dart are updated accordingly. No control flow or behavior changes are introduced. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
✨ 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. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
=======================================
Coverage 84.20% 84.20%
=======================================
Files 83 83
Lines 2716 2716
Branches 1480 1480
=======================================
Hits 2287 2287
Misses 429 429 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
lib/src/handler/handler.dart (1)
61-65: Update docstring: references to withResponse are staleDoc still says “for the
withResponsecall to succeed.” Should sayrespond.Apply this minimal diff:
-/// `withResponse` call to succeed. The handler ensures the resulting context is +/// `respond` call to succeed. The handler ensures the resulting context islib/src/adapter/context.dart (1)
41-41: Optional migration shim to ease external adopters off withResponse.To reduce churn for downstreams, consider a deprecated extension that forwards withResponse(...) to respond(...).
Add in a small compat file (e.g., lib/src/adapter/respond_compat.dart):
// Temporary shim for migration; remove in next major. extension RespondableContextWithResponseCompat on RespondableContext { @Deprecated('Use respond(Response) instead') ResponseContext withResponse(final Response r) => respond(r); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (9)
example/example.dart(1 hunks)lib/src/adapter/context.dart(4 hunks)lib/src/handler/handler.dart(1 hunks)lib/src/io/static/static_handler.dart(5 hunks)lib/src/middleware/middleware.dart(1 hunks)lib/src/relic_server.dart(2 hunks)test/middleware/routing_middleware_test.dart(8 hunks)test/static/test_util.dart(1 hunks)test/util/test_util.dart(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: nielsenko
PR: serverpod/relic#76
File: lib/src/handler/handler.dart:20-20
Timestamp: 2025-05-23T04:15:01.420Z
Learning: In the relic codebase, ResponseContext is a subtype of HandledContext, making functions with signature ResponseContext Function(RequestContext) assignable to the Handler typedef (FutureOr<HandledContext> Function(NewContext ctx)) due to covariant return types and contravariant parameter types in Dart's type system.
📚 Learning: 2025-05-23T04:15:01.420Z
Learnt from: nielsenko
PR: serverpod/relic#76
File: lib/src/handler/handler.dart:20-20
Timestamp: 2025-05-23T04:15:01.420Z
Learning: In the relic codebase, ResponseContext is a subtype of HandledContext, making functions with signature ResponseContext Function(RequestContext) assignable to the Handler typedef (FutureOr<HandledContext> Function(NewContext ctx)) due to covariant return types and contravariant parameter types in Dart's type system.
Applied to files:
lib/src/middleware/middleware.dartlib/src/handler/handler.darttest/middleware/routing_middleware_test.darttest/util/test_util.dartlib/src/relic_server.dartlib/src/adapter/context.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run Unit Tests (macos-latest, stable, downgrade)
- GitHub Check: Run Unit Tests (macos-latest, 3.5.0, downgrade)
🔇 Additional comments (8)
example/example.dart (1)
33-35: LGTM: rename to ctx.respond is correct and preserves return typeThe example aligns with the API change; returning ResponseContext remains valid for router usage (per covariant returns in this codebase).
test/static/test_util.dart (1)
46-51: LGTM: updated to ctx.respondThe not-found branch correctly uses the new respond API.
lib/src/handler/handler.dart (1)
66-68: LGTM: respondWith now uses ctx.respondFunctional behavior unchanged; naming is consistent with connect/hijack.
lib/src/middleware/middleware.dart (1)
56-70: LGTM: middleware paths updated to ctx/respond/respondEarly return, error path, and final post-processing all use respond; behavior preserved and types line up (ResponseContext implements respond).
test/util/test_util.dart (1)
27-33: LGTM: test helper now returns via ctx.respondSync helper continues to produce a ResponseContext; rename applied correctly.
test/middleware/routing_middleware_test.dart (1)
37-38: LGTM: tests updated to ctx.respond; type expectations still hold.Return types remain ResponseContext, satisfying Handler’s FutureOr. No behavioral changes.
Also applies to: 60-61, 85-86, 124-125, 160-161, 225-226, 266-267, 309-309
lib/src/relic_server.dart (1)
124-132: LGTM: middleware now uses rc.respond/ctx.respond; semantics preserved.Headers are augmented via copyWith + transform before responding; connect/hijack branches unchanged.
Also applies to: 141-143
lib/src/adapter/context.dart (1)
41-41: API rename solid and coherent with connect/hijack.Interfaces and implementations now expose respond(Response); call sites remain type-safe (ResponseContext ⊂ HandledContext).
Also applies to: 56-57, 76-78, 97-99
bf48ea0 to
e362193
Compare
…text.connect/hijack)
Description
Rename
RespondableContext.withResponsetoRespondableContext.respond. This aligns better with name of the member used, when setting up web socket connectionsNewContext.connect.Pre-Launch Checklist
Please ensure that your PR meets the following requirements before submitting:
///), ensuring consistency with existing project documentation.Breaking Changes
This PR renames a public method.
Summary by CodeRabbit
Refactor
Documentation
Tests
Chores