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

Default encoding of Enpoint.outStream[X] should be JSON array, or the Content Type should be application/json-seq #3113

Closed
gregor-rayman opened this issue Sep 7, 2024 · 6 comments · Fixed by #3122
Labels

Comments

@gregor-rayman
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Conceptually when an endpoint returns a list of X, it is the same as when it returns a ZStream[_, _, X]. Currently the default output encoding for .out[X] is an JSON array. For .outStream[X] it is however a not separated collection of JSONs. The Content-Type in the response is application/json, correct one would be application/json-seq.

Describe the solution you'd like
Either the data should be returned as a JSON array, so prefixed with [, separated by , and terminated by ], or the Content-Type should be application/json-seq. I'd prefer the array, because that makes the change change from .out[List[X]] to .outStream[X] an internal change of the server, without the need to change the clients.

Describe alternatives you've considered
A viable solution currently (RC10) is to provide custom codes for endpoints with .outStream[X] stream outputs.

@gregor-rayman gregor-rayman added the enhancement New feature or request label Sep 7, 2024
@jdegoes
Copy link
Member

jdegoes commented Sep 10, 2024

/bounty $125 to make .outStream[X] return a JSON array, and a test case to prove it.

Copy link

algora-pbc bot commented Sep 10, 2024

💎 $125 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3113 with your implementation plan
  2. Submit work: Create a pull request including /claim #3113 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
🟢 @gregor-rayman Sep 10, 2024, 11:46:36 AM #3122

@gregor-rayman
Copy link
Contributor Author

gregor-rayman commented Sep 10, 2024

/attempt #3113

Implement an encoder with the data interspersed with [, ,, ]

For the decoder parse the array incrementally, not as a single JSON array

Copy link

algora-pbc bot commented Sep 10, 2024

💡 @gregor-rayman submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Sep 20, 2024

@gregor-rayman: You've been awarded a $125 bounty by ZIO! 👉 Complete your Algora onboarding to collect the bounty.

Copy link

algora-pbc bot commented Sep 20, 2024

🎉🎈 @gregor-rayman has been awarded $125! 🎈🎊

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.

2 participants