scala - akka-http and JsonEntityStreamingSupport -


i'm doing experiment akka , persistency stack, wrapped akka-http stack.

note: persistency, i'm using non-official plugin persist akka fsm mongodb.

but problem using jsonentitystreamingsupport, recommended akka serve source json.

in case, have piece of code

implicit val jsonentitystreamingsupport: jsonentitystreamingsupport = entitystreamingsupport.json()  val readjournal = persistencequery(system).readjournalfor[scaladslmongoreadjournal](mongoreadjournal.identifier)  val route =   path("workflows") {     {       complete(readjournal.currentpersistenceids())     } }  http().bindandhandle(route, "localhost", 8081) 

but unfortunately, came error:

$ curl localhost:8081/workflows curl: (56) recv failure: connection reset peer 

i not see errors or logs lead information why server closing connection.

does done kind of experiment ?

i'm testing akka 2.4.16 , akka-http 10.0.5

ok, figured out.

readjournal.currentpersistenceids() gives me source[string, notused].

but, specified in akka-http specs,

this wrong since try render json, string not valid top level element need provide explicit marshaller[string, bytestring] if want render list of strings.

so have provide marshaller it. example, giving same tests :

implicit val stringformat = marshaller[string, bytestring] { ec ⇒ s ⇒   future.successful {     list(marshalling.withfixedcontenttype(contenttypes.`application/json`, () ⇒       bytestring("\"" + s + "\"")) // "raw string" rendered json element in our stream must enclosed ""     )   } } 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -