akka/akka-http
Vedi su GitHubWebSockets should use standard marshallers via TextMessage
Open
#281 aperta il 12 set 2016
1 - triagedhelp wantedt:websocket
Metriche repository
- Star
- (1311 star)
- Metriche merge PR
- (Merge medio 1g 10h) (2 PR mergiate in 30 g)
Descrizione
Issue by fommil Sunday Jul 12, 2015 at 11:36 GMT Originally opened as https://github.com/akka/akka/issues/17969
When using the new handleWebsocketMessages it is probably pretty reasonable to expect that the same marshallers will be used here as in the REST API (and at least the user could provide an implicit ToResponseMarshallable in the scope). However, handleWebsocketMessages expects a Flow[Message, Message, _] which demands that users manually implement the marshalling.
This results in this level of boilerplate:
val flow = Flow[Message].collect {
case TextMessage.Strict(msg) =>
msg.parseJson.convertTo[RpcRequestEnvelope]
// ignores everything else
}.via(Flow.wrap(sink, source)((_, _) => ())).map {
case e: RpcResponseEnvelope =>
TextMessage.Strict(e.toJson.prettyPrint): Message
}