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

Improve the efficiency of request handling in ZIO Http & Play #2747

Merged
merged 4 commits into from
Feb 20, 2023

Conversation

adamw
Copy link
Member

@adamw adamw commented Feb 20, 2023

The request is decoded once, and the decision whether a request should be handled by tapir is done based on the shape of the path

@frekw
Copy link
Contributor

frekw commented Feb 20, 2023

Amazing, great that you found a way to handle it @adamw! ❤️🎉

@adamw adamw merged commit 5d4afa9 into master Feb 20, 2023
@mergify mergify bot deleted the zio-http-better-path-decode branch February 20, 2023 19:57
@gaeljw
Copy link
Contributor

gaeljw commented Apr 4, 2023

FYI, we had a minor regression in a - I believe - corner case usage due to this change.

We had:

  • /api/something/ handled by Play router (routes file definition)
  • /api/something (no trailing slash) handled by Tapir router and redirecting to the trailing slash endpoint

Because both routes were considered as having the same shape, the runtime exception was raised.

The path: ... matches the shape of some endpoint, but none of the endpoints decoded the request successfully, and the decode failure handler didn't provide a response. Play requires that if the path shape matches some endpoints, the request should be handled by tapir.

The setup was a bit weird in the 1st place and thus we moved both routes in the same router (Play in our case) and no more issue.

I believe that's expected behaviour and acceptable but commenting to let others know about it :)

@adamw
Copy link
Member Author

adamw commented Apr 6, 2023

@gaeljw Ah yes, this does sound like a scenario where this would break. Btw. you can write a redirect-to-slash endpoint, e.g.

val redirectToSlashEndpoint = baseEndpoint
, using the noTrailingSlash input

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

Successfully merging this pull request may close these issues.

3 participants