wai-util-0.3: Collection of utility functions for use with WAI

Safe HaskellNone

Network.Wai.Util

Synopsis

Documentation

handleAcceptTypes :: Monad m => [(String, m Response)] -> Request -> m ResponseSource

Build an Application that supports multiple Accept types (Content Negotiation)

noStoreFileUploads :: BackEnd ()Source

BackeEnd for parseRequestBody that throws out any file uploads

bodyBytestring :: Request -> ResourceT IO ByteStringSource

Slurp in the entire request body as a ByteString

mapHeaders :: (ResponseHeaders -> ResponseHeaders) -> Response -> ResponseSource

Run a function over the headers in a Response

defHeader :: Header -> Response -> ResponseSource

Set a default value for a header in a Response

defHeader' :: Header -> ResponseHeaders -> ResponseHeadersSource

Set a default value for a header in ResponseHeaders

replaceHeader :: Header -> Response -> ResponseSource

Set the matching header name to this in a Response

replaceHeader' :: Header -> ResponseHeaders -> ResponseHeadersSource

Set the matching header name to this in ResponseHeaders

string :: Monad m => Status -> ResponseHeaders -> String -> m ResponseSource

Smart constructor to build a Response from a String

text :: Monad m => Status -> ResponseHeaders -> Text -> m ResponseSource

Smart constructor to build a Response from a Text

textBuilder :: Monad m => Status -> ResponseHeaders -> Builder -> m ResponseSource

Smart constructor to build a Response from a Builder

json :: (Monad m, ToJSON a) => Status -> ResponseHeaders -> a -> m ResponseSource

Smart constructor to build a JSON Response using Aeson

redirect :: Status -> ResponseHeaders -> URI -> Maybe ResponseSource

Smart constructor to build a redirect

Checks if the Status is a redirection and the URI is absolute

redirect' :: Monad m => Status -> ResponseHeaders -> URI -> m ResponseSource

Smart constructor to build a redirect

Asserts redirect conditions with an irrefutable pattern match, only use on hard-coded values.

stringAscii :: IsString s => String -> Maybe sSource

Safely convert a String to types that can only encode ASCII

stringHeader :: (IsString s1, IsString s2) => (String, String) -> Maybe (s1, s2)Source

Safely convert a pair of String to a pair suitable for use as a Header, ensuring only ASCII characters are present.

stringHeaders :: (IsString s1, IsString s2) => [(String, String)] -> Maybe [(s1, s2)]Source

Safely convert a list of pairs of String to a pair suitable for use as a Header, ensuring only ASCII characters are present.

stringHeaders' :: (IsString s1, IsString s2) => [(String, String)] -> [(s1, s2)]Source

Unsafely convert a list of pairs of String to a pair suitable for use as a Header, ensuring only ASCII characters are present.

Asserts success with an irrefutable pattern match, only use on hard-coded values.

responseToMailPart :: MonadIO m => Bool -> Response -> m PartSource

Convert a WAI Response to an email Part

Useful for re-using Application code/smart constructors to send emails