-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Webmachine inspired toolkit for building http applications and services. -- -- Webmachine inspired toolkit for building http applications and -- services. @package webcrank @version 0.2.2 module Webcrank.ServerAPI.WebcrankT -- | Monad transformer that can be used by server API providers. Provides -- tracking of the request state and logging of the decisions made so -- far. For example -- --
-- type WaiCrank m a = ReaderT (Request, HTTPDate) (WebcrankT m) a --newtype WebcrankT m a [WebcrankT] :: RWST (ResourceData (WebcrankT m)) LogData ReqData m a -> WebcrankT m a [unWebcrankT] :: WebcrankT m a -> RWST (ResourceData (WebcrankT m)) LogData ReqData m a runWebcrankT :: WebcrankT m a -> ServerAPI (WebcrankT m) -> Resource (WebcrankT m) -> ReqData -> m (a, ReqData, LogData) instance MonadMask m => MonadMask (WebcrankT m) instance MonadCatch m => MonadCatch (WebcrankT m) instance MonadThrow m => MonadThrow (WebcrankT m) instance Monad m => MonadWriter LogData (WebcrankT m) instance Monad m => MonadState ReqData (WebcrankT m) instance Monad m => MonadReader (ResourceData (WebcrankT m)) (WebcrankT m) instance MonadIO m => MonadIO (WebcrankT m) instance Monad m => Monad (WebcrankT m) instance Monad m => Applicative (WebcrankT m) instance Functor m => Functor (WebcrankT m) instance MonadTrans WebcrankT module Webcrank.Internal.DecisionCore data FlowChart m a [Decision] :: String -> m (FlowChart m a) -> FlowChart m a [Done] :: m a -> FlowChart m a decision :: String -> m (FlowChart m a) -> FlowChart m a decision' :: Functor m => String -> m Bool -> FlowChart m a -> FlowChart m a -> FlowChart m a done :: m a -> FlowChart m a done' :: (Applicative m, Monad m) => a -> FlowChart m a runFlowChart :: Monad m => FlowChart m a -> m a respond :: Monad m => Status -> FlowChart (HaltT m) Status errorResponse :: Monad m => Status -> ByteString -> HaltT m a errorResponse' :: Monad m => Status -> HaltT m a b13 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b12 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b11 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b10 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b9 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b8 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b6 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b4 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status b3 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status c3 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status c4 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status d4 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status d5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status e5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status e6 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status setCharsetFrom :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> HaltT m () f6 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status f7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status chooseEncoding :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> HaltT m () g7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status getVariances :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HaltT m [HeaderName] g8 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status g9 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status g11 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status h7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status h10 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status h11 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status h12 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HTTPDate -> FlowChart (HaltT m) Status i4 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status movedPermanentlyOr :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status -> HaltT m (FlowChart (HaltT m) Status) i7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status i12 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status i13 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status j18 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status k5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status k7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status k13 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status l5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status l7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status l13 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status l14 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => ByteString -> FlowChart (HaltT m) Status l15 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HTTPDate -> FlowChart (HaltT m) Status l17 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HTTPDate -> FlowChart (HaltT m) Status m5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status m7 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status m16 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status m20 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status n5 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status n11 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status appendPath :: ByteString -> [Text] -> ByteString splitURI :: ByteString -> (ByteString, ByteString) n16 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status o14 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status isConflict' :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HaltT m (FlowChart (HaltT m) Status) o16 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status o18 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status o20 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status p3 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status p11 :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => FlowChart (HaltT m) Status accept :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HaltT m () bool :: a -> a -> Bool -> a (<%%=) :: MonadState s m => Lens' s a -> (a -> m a) -> m () encodeBodyIfSet :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => HaltT m () encodeBody :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => Body -> HaltT m Body encodeBody' :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s) => Body -> m Body module Webcrank.Internal.Halt runHaltT :: HaltT m a -> m (Either Halt a) -- | Immediately end processing of the request, returning the response -- Status. It is the responsibility of the resource to ensure -- that all necessary response header and body elements have been added -- in order to make that response code valid. halt :: Monad m => Status -> HaltT m a -- | Immediately end processing of this request, returning a 500 -- Internal Server Error response. The response body will contain -- the reason. werror :: Monad m => ByteString -> HaltT m a -- | Immediately end processing of this request, returning a response with -- the given Status. The response body will contain the reason. werrorWith :: Monad m => Status -> ByteString -> HaltT m a module Webcrank.ServerAPI -- | A dictionary of functions that Webcrank needs in order to make -- decisions. data ServerAPI m [ServerAPI] :: m Method -> m ByteString -> (HeaderName -> m (Maybe ByteString)) -> m HTTPDate -> ServerAPI m -- | Get the request method of the current request. [srvGetRequestMethod] :: ServerAPI m -> m Method -- | The full URI of the request. [srvGetRequestURI] :: ServerAPI m -> m ByteString -- | Get the request header of the current request. [srvGetRequestHeader] :: ServerAPI m -> HeaderName -> m (Maybe ByteString) -- | Get the time the request was received. [srvGetRequestTime] :: ServerAPI m -> m HTTPDate -- | Container used to keep track of the decision state and what is known -- about response while processing a request. data ReqData -- | Smart constructor for creating a ReqData value with initial -- values. newReqData :: ReqData class HasReqData c_arV9 where reqDataDispPath = (.) reqData reqDataDispPath reqDataRespBody = (.) reqData reqDataRespBody reqDataRespCharset = (.) reqData reqDataRespCharset reqDataRespEncoding = (.) reqData reqDataRespEncoding reqDataRespHeaders = (.) reqData reqDataRespHeaders reqDataRespMediaType = (.) reqData reqDataRespMediaType reqData :: HasReqData c_arV9 => Lens' c_arV9 ReqData -- | A wrapper for the ServerAPI and -- Resource that should be used to process requests to a -- path. data ResourceData m newResourceData :: ServerAPI m -> Resource m -> ResourceData m class HasResourceData c_arRb m_apwF | c_arRb -> m_apwF where resourceDataResource = (.) resourceData resourceDataResource resourceDataServerAPI = (.) resourceData resourceDataServerAPI resourceData :: HasResourceData c_arRb m_apwF => Lens' c_arRb (ResourceData m_apwF) data LogData -- | Process a request according to the webmachine state diagram. Intended -- for use by server API providers. run is a function which can -- run process to completion. -- -- WebcrankT is provided as a starting point. For the -- type -- --
-- type WaiCrank = ReaderT (Request, HTTPDate) (WebcrankT IO) ---- -- an appropriate run function would be -- --
-- run :: Resource WaiCrank -> Request -> HTTPDate -> WaiCrank a -> IO (a, ReqData, LogData) -- run resource req date wa = runReaderT (runWebcrankT wa (ResourceData api resource) newReqData) (req, date) --handleRequest :: (Applicative m, MonadReader r m, HasResourceData r m, MonadState s m, HasReqData s, MonadCatch m, Functor n) => (forall a. m a -> n (a, ReqData, LogData)) -> n (Status, HeadersMap, Maybe Body) module Webcrank.Internal module Webcrank -- | A Resource is a dictionary of functions which are used in the -- Webcrank decision process to determine how requests should be handled. -- -- Each function has a type of either m a or HaltT m -- a. A resource function which yields a HaltT m a value -- allows the function to terminate the request processing early using -- halt or werror. -- -- The defaults documented are used by the resource -- smart constructor. A resource that responds to GET requests -- with an HTML response would be written as -- --
-- myResource = resource { contentTypesProvided = return $ [("text/html", return "Hello world!")] }
--
--
-- responseWithBody and
-- responseWithHtml are additional smart constructors
-- useful creating resources.
data Resource m
[Resource] :: HaltT m Bool -> HaltT m Bool -> m [Method] -> HaltT m Bool -> HaltT m Authorized -> HaltT m Bool -> HaltT m Bool -> HaltT m Bool -> HaltT m Bool -> m ResponseHeaders -> m [(MediaType, HaltT m Body)] -> m CharsetsProvided -> m [(Encoding, Body -> Body)] -> HaltT m Bool -> MaybeT m ETag -> MaybeT m HTTPDate -> MaybeT m HTTPDate -> MaybeT (HaltT m) ByteString -> MaybeT (HaltT m) ByteString -> HaltT m Bool -> HaltT m Bool -> HaltT m Bool -> HaltT m Bool -> m (PostAction m) -> m [(MediaType, HaltT m ())] -> m [HeaderName] -> HaltT m Bool -> m Bool -> m () -> Resource m
-- | False will result in 503 Service Unavailable.
-- Defaults to True.
[serviceAvailable] :: Resource m -> HaltT m Bool
-- | True will result in 414 Request Too Long. Defaults
-- to False.
[uriTooLong] :: Resource m -> HaltT m Bool
-- | If a Method not in this list is requested, then a 405
-- Method Not Allowed will be sent. Defaults to [GET,
-- HEAD].
[allowedMethods] :: Resource m -> m [Method]
-- | True will result in 400 Bad Request. Defaults to
-- False.
[malformedRequest] :: Resource m -> HaltT m Bool
-- | If Authorized, the response will be 401
-- Unauthorized. Unauthorized will be used as the challenge
-- in the WWW-Authenticate header, e.g. Basic
-- realm=Webcrank. Defaults to Authorized.
[isAuthorized] :: Resource m -> HaltT m Authorized
-- | True will result in 403 Forbidden. Defaults to
-- False.
[forbidden] :: Resource m -> HaltT m Bool
-- | False will result in 501 Not Implemented. Defaults
-- to True.
[validContentHeaders] :: Resource m -> HaltT m Bool
-- | False will result in 415 Unsupported Media Type.
-- Defaults to True.
[knownContentType] :: Resource m -> HaltT m Bool
-- | False will result in 413 Request Entity Too Large.
-- Defaults to True.
[validEntityLength] :: Resource m -> HaltT m Bool
-- | If the OPTIONS method is supported and is used, the headers that
-- should appear in the response. Defaults to [].
[options] :: Resource m -> m ResponseHeaders
-- | Content negotiation is driven by this function. For example, if a
-- client request includes an Accept header with a value that
-- does not appear as a MediaType in any of the tuples, then a
-- 406 Not Acceptable will be sent. If there is a matching
-- MediaType, that function is used to create the entity when a
-- response should include one. Defaults to [].
[contentTypesProvided] :: Resource m -> m [(MediaType, HaltT m Body)]
-- | Used on GET requests to ensure that the entity is in Charset.
-- Defaults to NoCharset.
[charsetsProvided] :: Resource m -> m CharsetsProvided
-- | Used on GET requests to ensure that the body is encoded. One useful
-- setting is to have the function check on method, and on GET requests
-- return [("identity", id), ("gzip", compress)] as this is all
-- that is needed to support gzip content encoding. Defaults to
-- [].
[encodingsProvided] :: Resource m -> m [(Encoding, Body -> Body)]
-- | False will result in 404 Not Found. Defaults to
-- True.
[resourceExists] :: Resource m -> HaltT m Bool
-- | If this returns an ETag, it will be used for the ETag header
-- and for comparison in conditional requests. Defaults to
-- mzero.
[generateETag] :: Resource m -> MaybeT m ETag
-- | If this returns a HTTPDate, it will be used for the
-- Last-Modified header and for comparison in conditional requests.
-- Defaults to mzero.
[lastModified] :: Resource m -> MaybeT m HTTPDate
-- | If this returns a HTTPDate, it will be used for the Expires
-- header. Defaults to mzero.
[expires] :: Resource m -> MaybeT m HTTPDate
-- | If this returns a URI, the client will receive a 301 Moved Permanently
-- with the URI in the Location header. Defaults to mzero.
[movedPermanently] :: Resource m -> MaybeT (HaltT m) ByteString
-- | If this returns a URI, the client will receive a 307 Temporary
-- Redirect with URI in the Location header. Defaults to mzero.
[movedTemporarily] :: Resource m -> MaybeT (HaltT m) ByteString
-- | If this returns True, the movedPermanently and
-- movedTemporarily callbacks will be invoked to determine
-- whether the response should be 301 Moved Permanently, 307 Temporary
-- Redirect, or 410 Gone. Defaults to False.
[previouslyExisted] :: Resource m -> HaltT m Bool
-- | If the resource accepts POST requests to nonexistent resources, then
-- this should return True. Defaults to False.
[allowMissingPost] :: Resource m -> HaltT m Bool
-- | This is called when a DELETE request should be enacted, and should
-- return True if the deletion succeeded or has been accepted.
-- Defaults to True.
[deleteResource] :: Resource m -> HaltT m Bool
-- | This is only called after a successful deleteResource call,
-- and should return False if the deletion was accepted but
-- cannot yet be guaranteed to have finished. Defaults to True.
[deleteCompleted] :: Resource m -> HaltT m Bool
-- | If POST requests should be treated as a request to put content into a
-- (potentially new) resource as opposed to being a generic submission
-- for processing, then this function should return PostCreate
-- path. If it does return PostCreate path, then the rest
-- of the request will be treated much like a PUT to the path entry.
-- Otherwise, if it returns PostProcess a, then the action
-- a will be run. Defaults to PostProcess $ return ().
[postAction] :: Resource m -> m (PostAction m)
-- | This is used similarly to contentTypesProvided, except that
-- it is for incoming resource representations -- for example,
-- PUT requests. Handler functions usually want to use server
-- specific functions to access the incoming request body. Defaults to
-- [].
[contentTypesAccepted] :: Resource m -> m [(MediaType, HaltT m ())]
-- | This function should return a list of strings with header names that
-- should be included in a given response's Vary header. The standard
-- conneg headers (Accept, Accept-Encoding, Accept-Charset,
-- Accept-Language) do not need to be specified here as Webcrank will add
-- the correct elements of those automatically depending on resource
-- behavior. Defaults to [].
[variances] :: Resource m -> m [HeaderName]
-- | If this returns True, then it is assumed that multiple
-- representations of the response are possible and a single one cannot
-- be automatically chosen, so a 300 Multiple Choices will be
-- sent instead of a 200 OK. Defaults to False.
[multipleChoices] :: Resource m -> HaltT m Bool
-- | If this returns True, the client will receive a 409 Conflict.
-- Defaults to False.
[isConflict] :: Resource m -> m Bool
-- | Called just before the final response is constructed and sent.
[finishRequest] :: Resource m -> m ()
-- | Builds a Resource m value where all the resource functions
-- will return default values as described in the
-- Resource function documentation.
resource :: Monad m => Resource m
-- | Creates a resource that provides a single content type.
resourceWithBody :: Monad m => MediaType -> m Body -> Resource m
-- | Creates a resource that provides a text/html content type.
resourceWithHtml :: Monad m => m Body -> Resource m
-- | Content coding type, e.g. gzip, decompress. See
-- encodingsProvided.
type Encoding = CI ByteString
-- | Indicates whether client is authorized to perform the requested
-- operation on the resource. See isAuthorized.
data Authorized
-- | Tells Webcrank that the client is authorized to perform the requested
-- operation on the resource.
[Authorized] :: Authorized
-- | Tells Webcrank that the client is not authorized to perform the
-- operation on the resource. The value is sent in the
-- WWW-Authenticate header of the response, e.g. Basic
-- realm=Webcrank.
[Unauthorized] :: ByteString -> Authorized
-- | Weak or strong entity tags as used in HTTP ETag and
-- If-*-Match headers.
data ETag
[StrongETag] :: ByteString -> ETag
[WeakETag] :: ByteString -> ETag
-- | How POST requests should be treated. See
-- postAction.
data PostAction m
-- | Treat POSTs as creating new resources and respond with
-- 201 Created, with the given path in the Location header.
[PostCreate] :: [Text] -> PostAction m
-- | Treat POSTs as creating new resources and respond with
-- 301 See Other, redirecting the client to the new resource.
[PostCreateRedir] :: [Text] -> PostAction m
-- | Treat POSTs as a process which is executed without redirect.
[PostProcess] :: (HaltT m ()) -> PostAction m
-- | Treat POSTs as a process and redirect the client to a
-- different (possibly new) resource.
[PostProcessRedir] :: (HaltT m ByteString) -> PostAction m
-- | Create a PostAction which performs resource creation without
-- redirecting.
postCreate :: Monad m => [Text] -> m (PostAction m)
-- | Create a PostAction which performs resource creation and
-- redirects.
postCreateRedir :: Monad m => [Text] -> m (PostAction m)
-- | Create a PostAction which runs some process and does not
-- redirect.
postProcess :: Monad m => HaltT m () -> m (PostAction m)
-- | Create a PostAction which runs some process and does
-- redirects.
postProcessRedir :: Monad m => HaltT m ByteString -> m (PostAction m)
-- | Monad transformer for Resource functions which can
-- halt the request processing early with an error or some other
-- response. Values are created with the smart constructors
-- werror and halt.
data HaltT m a
-- | Immediately end processing of the request, returning the response
-- Status. It is the responsibility of the resource to ensure
-- that all necessary response header and body elements have been added
-- in order to make that response code valid.
halt :: Monad m => Status -> HaltT m a
-- | Immediately end processing of this request, returning a 500
-- Internal Server Error response. The response body will contain
-- the reason.
werror :: Monad m => ByteString -> HaltT m a
-- | Immediately end processing of this request, returning a response with
-- the given Status. The response body will contain the reason.
werrorWith :: Monad m => Status -> ByteString -> HaltT m a
-- | The “local” path of the resource URI; the part after any prefix used
-- in dispatch configuration. Of the three path accessors, this is the
-- one you usually want. This is also the one that will change after
-- postAction is called in your resource.
getDispatchPath :: (MonadState s m, HasReqData s) => m [Text]
-- | Container used to keep track of the decision state and what is known
-- about response while processing a request.
data ReqData
class HasReqData c_arV9 where reqDataDispPath = (.) reqData reqDataDispPath reqDataRespBody = (.) reqData reqDataRespBody reqDataRespCharset = (.) reqData reqDataRespCharset reqDataRespEncoding = (.) reqData reqDataRespEncoding reqDataRespHeaders = (.) reqData reqDataRespHeaders reqDataRespMediaType = (.) reqData reqDataRespMediaType
-- | Character set type, e.g. utf-8. See charsetsProvided.
type Charset = CI ByteString
-- | Indicates whether the resource supports multiple character sets or
-- not. See charsetsProvided
data CharsetsProvided
-- | Indicates that the resource doesn't support any additional character
-- sets, all responses from the resource will have the same character
-- set, regardless of what the client requests.
[NoCharset] :: CharsetsProvided
-- | The character sets the resource supports along with functions for
-- converting the response body.
[CharsetsProvided] :: (NonEmpty (Charset, Body -> Body)) -> CharsetsProvided
-- | Shortcut for return . CharsetsProvided
provideCharsets :: Monad m => NonEmpty (Charset, Body -> Body) -> m CharsetsProvided
type HeadersMap = HashMap HeaderName [ByteString]
-- | Add a header to the response.
addResponseHeader :: (MonadState s m, HasReqData s) => HeaderName -> ByteString -> m ()
-- | Replace any existing response headers for the header name with the new
-- value.
putResponseHeader :: (MonadState s m, HasReqData s) => HeaderName -> ByteString -> m ()
-- | Response body type.
type Body = ByteString
-- | Create a response Body from a lazy ByteString.
lazyByteStringBody :: ByteString -> Body
-- | Create a response Body from a ByteString.
byteStringBody :: ByteString -> Body
-- | Create a response Body from lazy Text.
lazyTextBody :: Text -> Body
-- | Create a response Body from strict Text.
textBody :: Text -> Body
-- | Create a response Body from a String.
strBody :: String -> Body
-- | Use the Body as the response body.
writeBody :: (MonadState s m, HasReqData s) => ByteString -> m ()
-- | Use the lazy ByteString as the response body.
writeLBS :: (MonadState s m, HasReqData s) => ByteString -> m ()
-- | Use the ByteString as the response body.
writeBS :: (MonadState s m, HasReqData s) => ByteString -> m ()
-- | Use the lazy Text as the response body.
writeLT :: (MonadState s m, HasReqData s) => Text -> m ()
-- | Use the Text as the response body.
writeText :: (MonadState s m, HasReqData s) => Text -> m ()
-- | Use the String as the response body.
writeStr :: (MonadState s m, HasReqData s) => String -> m ()
hAcceptCharset :: HeaderName
hAcceptEncoding :: HeaderName
hAllow :: HeaderName
hETag :: HeaderName
hExpires :: HeaderName
hIfMatch :: HeaderName
hIfNoneMatch :: HeaderName
hIfUnmodifiedSince :: HeaderName
hTransferEncoding :: HeaderName
hVary :: HeaderName
hWWWAuthenticate :: HeaderName