wai-transformers-0.0.7: Simple parameterization of Wai's Application type

Copyright(c) 2015 Athan Clark
LicenseBSD-style
Maintainerathan.clark@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Network.Wai.Trans

Contents

Description

Simple utilities for embedding a monad transformer stack in an Application or Middleware - with MiddlewareT, your transformer stack is shared across all attached middlewares until run. You can also lift existing Middleware to MiddlewareT, given some extraction function.

Synopsis

WAI

Types

type ApplicationT m = Request -> (Response -> m ResponseReceived) -> m ResponseReceived #

Isomorphic to Kleisli (ContT ResponseReceived m) Request Response

Embedding

liftApplication :: MonadIO m => (forall a. m a -> IO a) -> Application -> ApplicationT m #

liftMiddleware :: MonadIO m => (forall a. m a -> IO a) -> Middleware -> MiddlewareT m #

runApplicationT :: MonadIO m => (forall a. m a -> IO a) -> ApplicationT m -> Application #

runMiddlewareT :: MonadIO m => (forall a. m a -> IO a) -> MiddlewareT m -> Middleware #

hoistApplicationT :: (Monad m, Monad n) => (forall a. m a -> n a) -> (forall a. n a -> m a) -> ApplicationT m -> ApplicationT n #

hoistMiddlewareT :: (Monad m, Monad n) => (forall a. m a -> n a) -> (forall a. n a -> m a) -> MiddlewareT m -> MiddlewareT n #

Exception catching

General Purpose

readingRequest :: Monad m => (Request -> m ()) -> MiddlewareT m #

Websockets

type ServerAppT m = PendingConnection -> m () #

runServerAppT :: (forall a. m a -> IO a) -> ServerAppT m -> ServerApp #

type ClientAppT m a = Connection -> m a #

runClientAppT :: (forall a. m a -> IO a) -> ClientAppT m a -> ClientApp a #

websocketsOrT :: MonadIO m => (forall a. m a -> IO a) -> ConnectionOptions -> ServerAppT m -> MiddlewareT m #

Respond with the WebSocket server when applicable, as a middleware