zio-http
zio-http copied to clipboard
Improve Routes DSL to support complex URI template patterns
Is your feature request related to a problem? Please describe. Extend capabilities of ZIO HTTP routes to cover use cases described in RFC 6570 - URI Template The issue that I came across is that the current ZIO Route DSL does not support defining complex use cases such as the following:
- multiple path variables in the same path segment, e.g,
http://example.com/people/{firstName}-{lastName}/SSN
- extractor and literal within the same path segment, e.g
http://example.com/people/{firstName}-some-literal/SSN
orhttp://example.com/people/some-literal-{firstName}/SSN
Just for reference: https://docs.micronaut.io/latest/guide/#routing, Many other frameworks, including Spring, Quarkus, dotnet, actix-web, implement the URI template specification. But no single scala HTTP library is capable of that.
It would be nice to have the flexibility to define complex routes via Route DSL and Endpoint DSL to have a well-designed and documented API.
It seems that it is not possible right now to define a route that will follow Resource Oriented API with custom methods (more details here)
I remember that something similar was discussed in the zio-http discord channel - https://discord.com/channels/629491597070827530/819703129267372113/1162396036237623326 but without proper resolution.
Describe the solution you'd like I want to have DLS that provide an ability to define
- multiple path variables in the same path segment:
POST / "virtual-machines" / string("vmId") / "instances" / PathCodec.combined(string("instanceId"), literal("_"), string("some_other_var"))
- extractor and literal within the same path segments
POST / "virtual-machines" / string("vmId") / "instances" / PathCodec.combined(string("instanceId"), literal(":reboot"))
Describe alternatives you've considered
@erikvanoosten, probably you have some ideas, coz I remember discussion in discord about problem related to this issue.
Additional context https://softwaremill.community/t/paths-components-without-separator/317
/bounty $750 for solution that does not impact performance and remains "zero allocation" and efficient, as well as backward compatible.
💎 $750 bounty • ZIO
Steps to solve:
-
Start working: Comment
/attempt #2679
with your implementation plan -
Submit work: Create a pull request including
/claim #2679
in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to zio/zio-http!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @bradovitt | Jun 23, 2024, 2:25:03 AM | WIP |
🟡 @kyri-petrou | Jun 30, 2024, 2:56:28 AM | #2959 |
🟢 @987Nabil | #2959 |
@bradovitt: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
/attempt #2679
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@kyri-petrou | 18 ZIO bounties | Scala, Python, Shell & more |
Cancel attempt |
[!NOTE] The user @bradovitt is already attempting to complete issue #2679 and claim the bounty. We recommend checking in on @bradovitt's progress, and potentially collaborating, before starting a new solution.
@kyri-petrou: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
💡 @987Nabil and @kyri-petrou submitted a pull request that claims the bounty. You can visit your bounty board to reward.