Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
data WebServer m a where Source #
StartWebServer :: Port -> (Request -> PendingWebRequest -> m ResponseReceived) -> WebServer m () | Starts a new web-server listening on a port, sending all requests to the provided function. |
StartWebServerSettings :: Settings -> (Request -> PendingWebRequest -> m ResponseReceived) -> WebServer m () | |
RespondWebRequest :: PendingWebRequest -> Response -> WebServer m ResponseReceived | Responds to a web request (usually called from the callback to StartWebServer. |
GetBody :: Int -> Request -> WebServer m (Maybe ByteString) | Reads the entire body of a request into memory. Takes a maximum length to read - if the body length exceeds this length, returns Nothing. |
UpgradeToWebSocketsResponse :: ConnectionOptions -> (PendingConnection -> m ()) -> Request -> WebServer m (Maybe Response) | Builds a response to upgrade a connection to a web socket. Returns Nothing if the request is not appropriate to upgrade. |
AcceptPendingWebSocketConnection :: PendingConnection -> AcceptRequest -> WebServer m (Either (Either HandshakeException ConnectionException) Connection) | Accepts a pending WebSockets connection. |
RejectPendingWebSocketConnection :: PendingConnection -> RejectRequest -> WebServer m () | Rejects a pending WebSockets connection. |
WhilePingingWebSocket :: Connection -> Int -> m a -> WebServer m (Maybe a) | Runs an app, and sends a ping message over the WebSockets connection every n seconds while the app is executing. When the app completes, the pings will also stop. |
SendWebSocketDataMessages :: Connection -> [DataMessage] -> WebServer m () | Sends some data messages over the WebSockets connection. |
ReceiveWebSocketDataMessage :: Connection -> WebServer m (Either ConnectionException DataMessage) | Receives a data message from the WebSockets connection. Returns a
Left |
SendWebSocketCloseCode :: WebSocketsData a => Connection -> Word16 -> a -> WebServer m () | Sends a friendly close message and close code on a WebSocket. See http://tools.ietf.org/html/rfc6455#section-7.4 for a list of close codes. |
Instances
type DefiningModule WebServer Source # | |
Defined in Polysemy.WebServer |
data PendingWebRequest Source #
startWebServer :: forall r. MemberWithError WebServer r => Port -> (Request -> PendingWebRequest -> Sem r ResponseReceived) -> Sem r () Source #
startWebServerSettings :: forall r. MemberWithError WebServer r => Settings -> (Request -> PendingWebRequest -> Sem r ResponseReceived) -> Sem r () Source #
respondWebRequest :: forall r. MemberWithError WebServer r => PendingWebRequest -> Response -> Sem r ResponseReceived Source #
getBody :: forall r. MemberWithError WebServer r => Int -> Request -> Sem r (Maybe ByteString) Source #
upgradeToWebSocketsResponse :: forall r. MemberWithError WebServer r => ConnectionOptions -> (PendingConnection -> Sem r ()) -> Request -> Sem r (Maybe Response) Source #
acceptPendingWebSocketConnection :: forall r. MemberWithError WebServer r => PendingConnection -> AcceptRequest -> Sem r (Either (Either HandshakeException ConnectionException) Connection) Source #
rejectPendingWebSocketConnection :: forall r. MemberWithError WebServer r => PendingConnection -> RejectRequest -> Sem r () Source #
whilePingingWebSocket :: forall r a. MemberWithError WebServer r => Connection -> Int -> Sem r a -> Sem r (Maybe a) Source #
sendWebSocketDataMessages :: forall r. MemberWithError WebServer r => Connection -> [DataMessage] -> Sem r () Source #
receiveWebSocketDataMessage :: forall r. MemberWithError WebServer r => Connection -> Sem r (Either ConnectionException DataMessage) Source #
sendWebSocketCloseCode :: forall r a. (MemberWithError WebServer r, WebSocketsData a) => Connection -> Word16 -> a -> Sem r () Source #