Hello folks,
I am trying to set up a zio-http server that expose a couple of websockets endpoint with tapir-zio-http-server, however ZioHttpInterpreter seems to be expecting to get a list of endpoint with ZioStreams only but using webSocketBody construct generate and endpoint with ZioStreams and WebSockets.
Question is there a way to support webSockets with ZioHttp?
object WebSocketApp extends zio.ZIOAppDefault {
override def run: ZIO[Any with ZIOAppArgs with Scope, Any, Any] = {
val pipe: stream.Stream[Throwable, WebSocketFrame] => stream.Stream[Throwable, WebSocketFrame] =
(s: stream.Stream[Throwable, WebSocketFrame]) => s.map(v => WebSocketFrame.text(s"echo: $v"))
val we: ZServerEndpoint[Nothing, ZioStreams] =
endpoint
.in("ws")
.out(webSocketBodyRaw(ZioStreams))
.zServerLogic(_ => ZIO.succeed(pipe))
val interpreter = ZioHttpInterpreter()
val http = interpreter.toHttp(we)
Server.install(http.withDefaultErrorResponse)
}
}