Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access latest route pattern when mapping route errors (#2823) #2915

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

987Nabil
Copy link
Contributor

@jdegoes When handling errors of Route.Unhandled, we accessed the current route pattern to decode it based on the incoming Request. When nesting, the route pattern of the handler changes, but the decoding was already constructed based on the pre-nesting route pattern.

I fixed this by changed the handler in Route.Handled to handler: Handler[Any, Nothing, RoutePattern[_], Handler[Env, Response, Request, Response]] and when calling toHandler, handing over the latest route pattern.

I considered instead manipulating the Request to remove the prefix when nesting, but decided that this is a bad idea, since the Request that the user might access would have a path, that does not reflect the path of the remote request.

fixes #2823
/claim #2823

@jdegoes jdegoes merged commit 3401d7d into zio:main Jun 18, 2024
62 checks passed
@jdegoes
Copy link
Member

jdegoes commented Jun 18, 2024

Good to have this one in! Algebraic laws FTW. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nesting routes work strange when handling errors
2 participants