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
ChunkAggregator for HttpRoutes and HttpApp #2429
ChunkAggregator for HttpRoutes and HttpApp #2429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This is going to get me in trouble with the OOphobes, but couldn't we have a trait for the middleware objects that provides this for all the middleware of this shape?
The reason I keep bringing up traits is that I still haven't seen another maintainable technique that doesn't add an import tax to the user. If typeclass syntax on the singleton types went into the implicits that are already imported, fine, but this would be implicits in another package, as well as a lawless typeclass. And I fail to see how it's worse than copy and paste. |
@rossabaker I have a feeling I've missed some of the earlier discussions around this topic. Could you please explain what you mean when you say "but this would be implicits in another package, as well as a lawless typeclass" ? In general I agree, it would be nice to give the middlewares a structure, where these kinds of shortcuts could be implemented in a general way. Let me dive into this and do some experiments. Meanwhile I am happy to park this PR until we can reach consensus. |
I think we can merge this because we don't have a consensus on a better way forward and have been arguing about this pattern for months. But I'd still like to solve this general problem in an agreeable way, because it keeps coming up. |
As far as I can see there's already a middleware type:
Which is good, but not really used in the code. Looking at the current middleware implementations it seems in most of the cases either the request or the response is fixed, sometimes both ( Probably not for the upcoming 0.20 release because of backwards compatibility, but if this is something worth to explore for future releases, I'd happily build a POC. |
I was thinking it couldn't be done without adding to the import tax, but I think that's wrong. Even though the middlewares all live in server or client, the shape of middleware is core, and could be in the org.http4s.implicits._ that many people already implement. I am not entirely comfortable adding syntax to general types to support things that aren't typeclasses, but that's exactly what we've done with I don't have a strong opinion. Does anyone else? |
I think we should open a separate issue, because there was consensus to move forward with this. |
This PR adds convenience shortcuts to the ChunkAggregattor to apply the middleware on HttpRoutes and HttpApps.
Related issue: #2402