Repository navigation
feat: Surface RelicRouter.fallback in WebServer" - #4076
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 Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThis PR migrates the Serverpod web server from a Router-based routing architecture to RelicApp, updates the relic dependency to a git-based pre-release version, adopts lazy factory initialization for IOAdapter, and refactors the Route interface and middleware hierarchy to align with the new routing framework. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RelicApp
participant Route as Route<br/>(extends HandlerObject)
participant Middleware as Middleware<br/>(extends MiddlewareObject)
participant Handler
Client->>RelicApp: HTTP Request
RelicApp->>Middleware: apply middleware chain
Middleware->>RelicApp: next (handler)
RelicApp->>Route: route.injectIn(router)
Route->>Route: anyOf(methods, path, asHandler)
Route->>Handler: asHandler conversion
Handler->>Route: call(context)
Route->>Client: response
Note over RelicApp,Handler: New flow: RelicApp groups routes<br/>and injects via injectIn(router)
sequenceDiagram
participant Code
participant RelicServer
participant IOAdapter
participant HttpServer
Code->>RelicServer: RelicServer(() => IOAdapter(...))
Note over Code,RelicServer: Factory function passed (lazy init)
RelicServer->>RelicServer: start()
RelicServer->>IOAdapter: invoke factory: () => IOAdapter(...)
IOAdapter->>HttpServer: bind to port
HttpServer->>RelicServer: server ready
Code->>RelicServer: server.port
RelicServer->>Code: bound port (from HttpServer)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes This PR contains substantial architectural changes to the routing system (Router → RelicApp), public API modifications to the Route interface, middleware hierarchy refactoring, and consistent cross-package dependency updates. While the changes follow a cohesive pattern, they span multiple interconnected files and require verification of the migration logic, middleware injection correctness, and adapter lazy initialization semantics. Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
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. Comment |
|
You can disregard the analysis errors. These are due to the git ref introduced in 4f25093. The particular commit will be replaced before merge, once relic 0.8.0 is released. |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for custom fallback routes in WebServer by exposing the RelicRouter.fallback functionality. When set, the fallback route is invoked for unmatched requests instead of returning the default "404 Not Found" response.
Key changes:
- Migrates
WebServerfromRoutertoRelicAppto support the fallback route API - Updates
Routeto extendHandlerObjectwith apathproperty for suffix path handling - Updates Relic dependency to git reference
nielsenko/[email protected]
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/serverpod/lib/src/web_server/web_server.dart | Migrates from Router to RelicApp, adds fallbackRoute setter, updates middleware to extend MiddlewareObject, adds path property to Route class |
| packages/serverpod/lib/src/web_server/routes/static_route.dart | Updates StaticRoute to use StaticHandler constructors instead of create functions |
| packages/serverpod/lib/src/server/server.dart | Updates RelicServer initialization to use adapter factory function |
| packages/serverpod_client/test/test_utils/test_web_socket_server.dart | Updates test server to use IOAdapter.bind factory and server.port property |
| packages/serverpod_client/test/test_utils/test_http_server.dart | Updates test server to use IOAdapter.bind factory and server.port property |
| packages/serverpod/pubspec.yaml | Updates relic dependency to git source |
| packages/serverpod_client/pubspec.yaml | Updates relic dependency to git source |
| templates/pubspecs/packages/serverpod/pubspec.yaml | Updates relic dependency template to git source |
| templates/pubspecs/packages/serverpod_client/pubspec.yaml | Updates relic dependency template to git source |
| templates/pubspecs/tests/serverpod_test_server/pubspec.yaml | Updates relic dependency template to git source |
| tests/serverpod_test_server/pubspec.yaml | Updates relic dependency to git source |
SandPod
left a comment
There was a problem hiding this comment.
Changes looks good! Just had one suggestion.
But let's not merge it until we have a relic to keep main shippable.
…are object used throughout.
7800779 to
9b9032e
Compare
|
Rebased after release of relic 0.8.0. |
Description
Adds
WebServer.fallbackRouteproperty to allow custom handling of unmatched requests. When set, the fallback route is invoked instead of the default "404 Not Found" response.Additional changes to support this feature:
WebServerto useRelicAppinstead ofRouter, migrating middleware and route handling to the new APIRouteto extendHandlerObjectand adds apathproperty that determines the suffix path where the route respondspathparameter inWebServer.addRouteoptional, defaulting to/StaticRouteto useStaticHandlerconstructors instead ofcreateStaticHandlerandcreateFileHandlernielsenko/prep-0.8.0to support new APIsFixes: #4042
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.Breaking changes
Routenow extendsHandlerObjectand includes apathproperty. Technically this is a breaking change, since you can implementRouteinstead of extending it.Summary by CodeRabbit
Refactor
Chores