| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Web.Hyperbole.Application
Synopsis
- waiApplication :: Route route => (ByteString -> ByteString) -> (route -> Eff '[Hyperbole, IOE] ()) -> Application
- application :: Route route => (ByteString -> ByteString) -> (route -> Eff '[Hyperbole, IOE] ()) -> Application
- websocketsOr :: ConnectionOptions -> ServerApp -> Application -> Application
Documentation
waiApplication :: Route route => (ByteString -> ByteString) -> (route -> Eff '[Hyperbole, IOE] ()) -> Application Source #
application :: Route route => (ByteString -> ByteString) -> (route -> Eff '[Hyperbole, IOE] ()) -> Application Source #
Start both a websockets and a WAI server. Wai app serves initial pages, and attempt to process actions via sockets If the socket connection is unavailable, will fall back to the WAI app to process actions
websocketsOr :: ConnectionOptions -> ServerApp -> Application -> Application #
Upgrade a websockets ServerApp to a wai Application. Uses
the given backup Application to handle Requests that are not
WebSocket requests.
websocketsOr opts ws_app backup_app = \req respond ->
case websocketsApp opts ws_app req of
Nothing -> backup_app req send_response
Just res -> respond res
For example, below is an Application that sends "Hello, client!" to
each connected client.
app ::Applicationapp =websocketsOrdefaultConnectionOptionswsApp backupApp where wsApp ::ServerAppwsApp pending_conn = do conn <-acceptRequestpending_connsendTextDataconn ("Hello, client!" ::Text) backupApp ::ApplicationbackupApp _ respond = respond $responseLBSstatus400[] "Not a WebSocket request"