hseeberger / akka-http-json

Integrate some of the best JSON libs in Scala with Akka HTTP
Apache License 2.0
591 stars 135 forks source link

Consuming akka-http JSON streaming does not seem to work with akka-http-circe #204

Open akauppi opened 6 years ago

akauppi commented 6 years ago

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).

akauppi commented 6 years ago

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])
hseeberger commented 6 years ago

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.

akauppi commented 6 years ago

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).

hseeberger commented 6 years ago

Yeah, entity streaming is definitely a missing feature. Please give it a try.

akauppi commented 6 years ago

Thanks for mentioning Server-Sent Events. I may be using those in my actual case, but let's return to this at some point.

gabfssilva commented 4 years ago

I guess #347 solved this issue.