Endpoint for defining a route to provide a websocket. In contrast
to the WebSocket endpoint, WebSocketConduit provides a
higher-level interface. The handler function must be of type
Conduit i m o with i and o being instances of FromJSON and
ToJSON respectively. await reads from the web socket while
yield writes to it.
Example:
import Data.Aeson (Value)
import qualified Data.Conduit.List as CL
type WebSocketApi = "echo" :> WebSocketConduit Value Value
server :: Server WebSocketApi
server = echo
where
echo :: Monad m => ConduitT Value Value m ()
echo = CL.map id
Note that the input format on the web socket is JSON, hence this example only echos valid JSON data.
Instances2HasServer, ServerT
(FromJSON i, ToJSON o) => HasServer (WebSocketConduit i o) ctxDefined in servant-websockets-2.0.0 · Servant.API.WebSocketConduittype ServerT (WebSocketConduit i o) m = ConduitT i o (ResourceT IO) ()Defined in servant-websockets-2.0.0 · Servant.API.WebSocketConduit