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

Safe HaskellNone
LanguageHaskell98

Network.Wai.Util

Synopsis

Documentation

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

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

noStoreFileUploads :: BackEnd () Source

BackeEnd for parseRequestBody that throws out any file uploads

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

Run a function over the headers in a Response

defHeader :: Header -> Response -> Response Source

Set a default value for a header in a Response

defHeader' :: Header -> ResponseHeaders -> ResponseHeaders Source

Set a default value for a header in ResponseHeaders

replaceHeader :: Header -> Response -> Response Source

Set the matching header name to this in a Response

replaceHeader' :: Header -> ResponseHeaders -> ResponseHeaders Source

Set the matching header name to this in ResponseHeaders

string :: Monad m => Status -> ResponseHeaders -> String -> m Response Source

Smart constructor to build a Response from a String

text :: Monad m => Status -> ResponseHeaders -> Text -> m Response Source

Smart constructor to build a Response from a Text

textBuilder :: Monad m => Status -> ResponseHeaders -> Builder -> m Response Source

Smart constructor to build a Response from a Builder

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

Smart constructor to build a JSON Response using Aeson

bytestring :: (IsByteString bs, Monad m) => Status -> ResponseHeaders -> bs -> m Response Source

Smart constructor to build a Response from a ByteString

redirect :: Status -> ResponseHeaders -> URI -> Maybe Response Source

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 Response Source

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 s Source

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.

queryLookup :: (QueryLike q, QueryKeyLike k) => k -> q -> Maybe Text Source

Lookup a given key in something that acts like a query

queryLookupAll :: (QueryLike q, QueryKeyLike k) => k -> q -> [Text] Source

Get all matches for a given key in something that acts like a query