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

Properly support content type headers in zio.http.api #1506

Closed
jdegoes opened this issue Sep 18, 2022 · 11 comments · Fixed by #2366
Closed

Properly support content type headers in zio.http.api #1506

jdegoes opened this issue Sep 18, 2022 · 11 comments · Fixed by #2366
Labels
💎 Bounty enhancement New feature or request 💰 Rewarded ziohackathon An official ticket for ZIO Hackathon

Comments

@jdegoes
Copy link
Member

jdegoes commented Sep 18, 2022

Is your feature request related to a problem? Please describe.

Currently, EndpointClient and EndpointServer in zio.http.api.internal do not perform an adequate job supporting and respecting content type headers.

Describe the solution you'd like

Modify the client and server to respect and generate the appropriate content type headers, and enhance the architecture to support any one of the protocols supported by ZIO Schema, which powers the current JSON support.

Describe alternatives you've considered

None.

Additional context

See /src/main/scala/zio/http/api/internal/ EndpointClient.scala and EndpointServer.scala.

@jdegoes
Copy link
Member Author

jdegoes commented Apr 18, 2023

In particular, since ZIO Schema supports several different protocols, including gRPC, endpoints should properly support those protocols, based on Accept headers.

@jdegoes
Copy link
Member Author

jdegoes commented Apr 18, 2023

/bounty $250

@algora-pbc
Copy link

algora-pbc bot commented Apr 18, 2023

💎 $250 bounty created by jdegoes
🙋 If you start working on this, comment /attempt #1506 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #1506 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to zio/zio-http!

Attempt Started (GMT+0) Solution
🟢 @987Nabil #2366

@987Nabil
Copy link
Contributor

987Nabil commented May 6, 2023

@jdegoes the only protocol besides json, that zio-schema supports and does have an official mime-type is thrift.
protobuf for example does not have one.
I would suggest, that users can configure on which accept header to reply with which protocol. And that this config has default values for json and thrift. We could also add default values for protobuf for example, that has commonly used values, even if they are not official. But I think to make it configurable is needed to make it usable in the wild.

@jdegoes
Copy link
Member Author

jdegoes commented May 8, 2023

@987Nabil I would rather not make it configurable and choose based solely on Accept, because making it configurable will require figuring out a difficult API, whereas the main task here is just plumbing and architecture and tests, which doesn't require any R&D.

@jdegoes
Copy link
Member Author

jdegoes commented May 8, 2023

application/protobuf is as close to standard as it gets for Protobuf. Official standards seem to get hung up on the question of determining message type, which we don't need for microservices because we generate the client which knows the type.

@987Nabil
Copy link
Contributor

987Nabil commented May 8, 2023

@jdegoes but which accept values? There is no standard.

@987Nabil
Copy link
Contributor

987Nabil commented May 8, 2023

Let's say that is okay for protobuf and the case you described. What about the other formats?
What about the case that users don't own both sides?

@987Nabil
Copy link
Contributor

/attempt #1506

@algora-pbc
Copy link

algora-pbc bot commented Aug 4, 2023

💡 @987Nabil submitted a pull request that claims the bounty. You can visit your org dashboard to reward.

@algora-pbc
Copy link

algora-pbc bot commented Aug 15, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty enhancement New feature or request 💰 Rewarded ziohackathon An official ticket for ZIO Hackathon
Projects
2 participants