akka-http-json
akka-http-json copied to clipboard
Consuming akka-http JSON streaming does not seem to work with akka-http-circe
I got server side working, but have problems with the client side.
https://doc.akka.io/docs/akka-http/current/common/json-support.html#consuming-json-streaming-style-apis
The akka-http samples are made with Spray-json. I'm trying to replicate the same, using Circe and akka-http-circe.
Note: This is just an early warning. Looking into what's the problem, precisely (so I can expose a repo that showcases it, in a few days).
The code is available (I'm implying I could use some help...) here: https://github.com/akauppi/akka-http-circe-streaming-sample
Compilation fails with:
Error:(54, 54) could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.Unmarshaller[akka.util.ByteString,sandbox.Data]
.mapAsync(1)(bytes => Unmarshal(bytes).to[Data])
Error:(54, 54) not enough arguments for method to: (implicit um: akka.http.scaladsl.unmarshalling.Unmarshaller[akka.util.ByteString,sandbox.Data], implicit ec: scala.concurrent.ExecutionContext, implicit mat: akka.stream.Materializer)scala.concurrent.Future[sandbox.Data].
Unspecified value parameters um, mat.
.mapAsync(1)(bytes => Unmarshal(bytes).to[Data])
Thanks. I don't have the time to investigate this now. BTW, for you use case you might also take a look at Server-Sent Events and in particular to the SSE support in Alpakka.
No problem. I got the hop running, and my question rather is whether you see this to be within the scope of akka-http-circe, or not.
I hope you do. :) Akka-http-json is the "go to" place for integrating e.g. Circe with akka-http, and it's so nice when things just work. Since Akka HTTP now provides support for JSON streaming (and since the server side already works), it would make sense to allow also the client side to do so.
For me, that meant doing this unmarshaller (link).
I don't have the chance to make a proper PR right now, but if you see the feature as a welcome inclusion, I may do so later (within some weeks, or a month).
Yeah, entity streaming is definitely a missing feature. Please give it a try.
Thanks for mentioning Server-Sent Events. I may be using those in my actual case, but let's return to this at some point.
I guess #347 solved this issue.