Conversation
`RouteHandler` was the one core trait that exposed its boxing: `handle`
returned a public `RouteHandlerFuture` alias, so every implementor wrote
`Box::pin(async move { .. })` by hand, while `Middleware` hides the same
boxing behind an internal erased trait. Both traits now work the same way.
`handle` returns `impl Future + MaybeSend`, implementors write `async fn`,
and a `pub(crate) ErasedRouteHandler` blanket impl boxes the future for
`Router`'s `Box<dyn ..>` storage. `RouteHandlerFuture` becomes crate-private.
The OIDC and STS handlers drop their `Box::pin` wrappers, and the
request-lifecycle doc replaces a stale example that referenced per-method
hooks (`get`, `post`) the trait never had.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Claude finished @alukach's task in 14s —— View job ✅ No blocking issues — safe to merge. I read the full diff and found no correctness or security problems.
Simplify (ponytail)
💰 Estimated review cost: $0.12 · 0m13s · 4 turns |
|
📖 Docs preview deployed to https://multistore-docs-pr-156.development-seed.workers.dev
|
|
🚀 Latest commit deployed to https://multistore-proxy-pr-156.development-seed.workers.dev
|
alukach
marked this pull request as ready for review
October 1, 2026 17:03
Resolve conflict in crates/sts/src/route_handler.rs: keep the async fn form of StsHandler::handle and carry over main's GetCallerIdentity dispatch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I'm changing
RouteHandlerwas the odd one out among the core traits.Middleware,ProxyBackend, and the registries all use native return-positionimpl Futuremethods, andMiddlewarehides the object-safety boxing behind an internalErasedMiddlewareblanket impl.RouteHandler::handleinstead returned a publicRouteHandlerFuture = Pin<Box<dyn Future ..>>, so every implementor (OIDC discovery, JWKS, STS, and anyone writing a health check) had to writeBox::pin(async move { .. })by hand and handle the early-return case withreturn Box::pin(async { None }).This PR applies the
Middlewarepattern toRouteHandler. Implementors writeasync fn handle, and the router boxes internally.How I did it
crates/core/src/route_handler.rs:RouteHandler::handlenow returnsimpl Future<Output = Option<ProxyResult>> + MaybeSend + 'a. A newpub(crate) trait ErasedRouteHandlerwith a blanketimpl<T: RouteHandler>does theBox::pin.RouteHandlerFuturebecomespub(crate); it was only ever useful for satisfying the old signature. The trait doc example shows theasync fnform and links toMiddlewareas the precedent.crates/core/src/router.rs: storesBox<dyn ErasedRouteHandler>. Theroute()signature is unchanged (impl RouteHandler + 'static), so callers are unaffected. Adds a unit test with aHealthCheckhandler written exactly as an integrator would, checking dispatch, decline (None), and no-match.crates/oidc-provider/src/route_handler.rs,crates/sts/src/route_handler.rs: the three handlers becomeasync fnbodies; the STS handler'stry_handle_sts(..).await?now uses?onOptiondirectly inside the async fn.docs/architecture/request-lifecycle.md: the "Method routing" section describedget/post/puthooks that the trait never had and showedBox::pin. Replaced with an "Implementing a handler" section matching the real API.This is a breaking change for external
RouteHandlerimplementors: drop theBox::pinand changefn handle(..) -> RouteHandlerFuture<'a>toasync fn handle(..) -> Option<ProxyResult>.Test plan
cargo test— 293 passed (newrouter::tests::async_fn_handler_dispatches_and_falls_through; STS route-handler tests exercise the erased path)cargo check --all-targetscargo check -p multistore-cf-workers --target wasm32-unknown-unknown(theMaybeSendno-op path)cargo check -p multistore-cf-workers-example --target wasm32-unknown-unknowncargo clippy -- -D warningscargo fmt --check🤖 Generated with Claude Code