-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Accept header branching for the Snap web framework -- -- HTTP media type functionality as a complement to Snap's method -- and methods functions. Branches based on the value of the -- Accept or Accept-Language header of the current request, automatically -- setting the Content-Type or Content-Language header of the response as -- appropriate. @package snap-accept @version 0.2.0 -- | HTTP media type functionality as a complement to Snap's method -- and methods functions. Branches based on the value of the -- Accept or Accept-Language header of the current request, automatically -- setting the Content-Type or Content-Language header of the response as -- appropriate. module Snap.Accept -- | 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. accept :: (FromHeader a, MonadSnap m) => a -> m b -> m b -- | The accept function but specialised to MediaType. acceptMedia :: (MonadSnap m) => MediaType -> m a -> m a -- | The accept function but specialised to Language. acceptLanguage :: (MonadSnap m) => Language -> m a -> m a -- | 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. accepts :: (FromHeader a, MonadSnap m) => [(a, m b)] -> m b -- | The accepts function but specialised to MediaType. acceptsMedia :: (MonadSnap m) => [(MediaType, m a)] -> m a -- | The accepts function but specialised to Language. acceptsLanguage :: (MonadSnap m) => [(Language, m a)] -> m a -- | An HTTP media type, consisting of the type, subtype, and parameters. data MediaType :: * -- | Suitable for HTTP language-ranges as defined in RFC2616. -- -- Specifically: -- --
-- language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) --data Language :: * -- | 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. class (Accept a, RenderHeader a) => FromHeader a -- | The name of the corresponding Accept* header for this type. requestName :: FromHeader a => Proxy a -> CI ByteString -- | The name of the corresponding Content-* header for this type. responseName :: FromHeader a => Proxy a -> CI ByteString -- | The default header value to use if the header is absent. defaultValue :: FromHeader a => Proxy a -> ByteString instance Snap.Accept.FromHeader Network.HTTP.Media.MediaType.Internal.MediaType instance Snap.Accept.FromHeader Network.HTTP.Media.Language.Internal.Language