Safe Haskell | None |
---|---|
Language | Haskell2010 |
- accept :: (FromHeader a, MonadSnap m) => a -> m b -> m b
- acceptMedia :: MonadSnap m => MediaType -> m a -> m a
- acceptLanguage :: MonadSnap m => Language -> m a -> m a
- accepts :: (FromHeader a, MonadSnap m) => [(a, m b)] -> m b
- acceptsMedia :: MonadSnap m => [(MediaType, m a)] -> m a
- acceptsLanguage :: MonadSnap m => [(Language, m a)] -> m a
- data MediaType :: *
- data Language :: *
- class (Accept a, RenderHeader a) => FromHeader a where
Branching
accept :: (FromHeader a, MonadSnap m) => a -> m b -> m b Source #
Runs a Snap monad only if the request's Accept* header allows for the given value. If accepted, the response's Content-* header is automatically filled in.
acceptMedia :: MonadSnap m => MediaType -> m a -> m a Source #
acceptLanguage :: MonadSnap m => Language -> m a -> m a Source #
accepts :: (FromHeader a, MonadSnap m) => [(a, m b)] -> m b Source #
Matches the Accept* header of the request to each of the values in the pairs of the given list, running the corresponding Snap monad in the pair that is most desired by the client. If two or more results arise with the same quality level and specificity, then the pair that appears earliest in the list is matched. On any match, the response's Content-* header is automatically filled in.
acceptsMedia :: MonadSnap m => [(MediaType, m a)] -> m a Source #
acceptsLanguage :: MonadSnap m => [(Language, m a)] -> m a Source #
Accept types
An HTTP media type, consisting of the type, subtype, and parameters.
Suitable for HTTP language-ranges as defined in RFC2616.
Specifically:
language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
Header names
class (Accept a, RenderHeader a) => FromHeader a where Source #
The class of values that represent some Accept* header in a request and corresponding Content-* header in a response, such that the name of the header can be retrieved from the type.
requestName :: Proxy a -> CI ByteString Source #
The name of the corresponding Accept* header for this type.
responseName :: Proxy a -> CI ByteString Source #
The name of the corresponding Content-* header for this type.
defaultValue :: Proxy a -> ByteString Source #
The default header value to use if the header is absent.