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 Routes DSL to support complex URI template patterns #2679

Closed
limpid-kzonix opened this issue Feb 18, 2024 · 10 comments · Fixed by #2959
Closed

Improve Routes DSL to support complex URI template patterns #2679

limpid-kzonix opened this issue Feb 18, 2024 · 10 comments · Fixed by #2959
Labels

Comments

@limpid-kzonix
Copy link

limpid-kzonix commented Feb 18, 2024

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 or http://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.

image

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

@jdegoes
Copy link
Member

jdegoes commented Jun 5, 2024

/bounty $750 for solution that does not impact performance and remains "zero allocation" and efficient, as well as backward compatible.

Copy link

algora-pbc bot commented Jun 5, 2024

💎 $750 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #2679 with your implementation plan
  2. Submit work: Create a pull request including /claim #2679 in the PR body to claim the bounty
  3. 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 bountyShare 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
Copy link

bradovitt commented Jun 23, 2024

/attempt #2679

Copy link

algora-pbc bot commented Jun 30, 2024

@bradovitt: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@kyri-petrou
Copy link
Collaborator

kyri-petrou commented Jun 30, 2024

/attempt #2679

Algora profile Completed bounties Tech Active attempts Options
@kyri-petrou 18 ZIO bounties
Scala, Python,
Shell & more
Cancel attempt

Copy link

algora-pbc bot commented Jun 30, 2024

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.

987Nabil added a commit to 987Nabil/zio-http that referenced this issue Jul 6, 2024
Copy link

algora-pbc bot commented Jul 7, 2024

@kyri-petrou: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

Copy link

algora-pbc bot commented Jul 13, 2024

💡 @987Nabil and @kyri-petrou submitted a pull request that claims the bounty. You can visit your bounty board to reward.

jdegoes pushed a commit that referenced this issue Jul 15, 2024
* First pass on segment codecs

* Allocation free path checking (#2679)

* Improve API to generate combined segments and enforce structure (#2679)

---------

Co-authored-by: Kyri Petrou <kyri.petrou@outlook.com>
Copy link

algora-pbc bot commented Jul 15, 2024

🎉🎈 @987Nabil has been awarded $375! 🎈🎊

Copy link

algora-pbc bot commented Jul 15, 2024

🎉🎈 @kyri-petrou has been awarded $375! 🎈🎊

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

Successfully merging a pull request may close this issue.

4 participants