| Safe Haskell | Trustworthy |
|---|
LIO.Web.Simple
Description
This module defines several instances needed to use LIO as the
underlying monad with Web.Simple, the simple web framework.
Additionally, we provide some middleware for executing apps in a safe
manner.
LIO.Web.Simple.TCB defines several functions that can be used to
execute LIO web applications with the Warp server.
- body :: Label l => LIOController l r ByteString
- parseForm :: Label l => LIOController l r ([Param], [(ByteString, FileInfo ByteString)])
- browserLabelGuard :: MonadLIO l m => l -> SimpleMiddleware m
- removeRequestHeaders :: Monad m => [HeaderName] -> SimpleMiddleware m
- removeResponseHeaders :: Monad m => [HeaderName] -> SimpleMiddleware m
- type SimpleLIOApplication p l = Priv p -> SimpleApplication (LIO l)
- type SimpleLIOMiddleware p l = SimpleLIOApplication p l -> SimpleLIOApplication p l
- type LIOController l s = ControllerT s (LIO l)
- module Web.Simple.Responses
- module Web.Simple.Templates
- module Web.Simple.Controller.Trans
Utilities for parsing request
body :: Label l => LIOController l r ByteStringSource
Parses a HTML form from the request body. It returns a list of Params as
well as a list of Files, which are pairs mapping the name of a file form
field to a FileInfo pointing to a temporary file with the contents of the
Reads and returns the body of the HTTP request.
Note: body function consumes the body from a Source IO
Bytestring. Since the Request constructor is exposed by
Network.Wai.Internal, it's important to disallow construction of
such values when considering untrusted code.
parseForm :: Label l => LIOController l r ([Param], [(ByteString, FileInfo ByteString)])Source
Middleware
browserLabelGuard :: MonadLIO l m => l -> SimpleMiddleware mSource
Middleware that ensures the Response from the
application is readable by the client's browser (as determined by the
result label of the app computation and the label of the browser). If
the response is not readable by the browser, the middleware sends a
403 (unauthorized) response instead.
removeRequestHeaders :: Monad m => [HeaderName] -> SimpleMiddleware mSource
Remove certain headers from the request.
removeResponseHeaders :: Monad m => [HeaderName] -> SimpleMiddleware mSource
Remove certain headers from the response, e.g., Set-Cookie.
LIO applications
type SimpleLIOApplication p l = Priv p -> SimpleApplication (LIO l)Source
An LIO simple aplpication is an LIO computation mapping a set
of privileges and request to a response. While privileges can be
provided in terms of a e.g., Reader monad, in certain cases not
having the privilege as part of the sate is cleaner.
type SimpleLIOMiddleware p l = SimpleLIOApplication p l -> SimpleLIOApplication p lSource
Simple LIO middleware.
type LIOController l s = ControllerT s (LIO l)Source
Controller with LIO as the underlying monad.
Relevant modules
module Web.Simple.Responses
module Web.Simple.Templates
module Web.Simple.Controller.Trans