Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ETag
- data Webmachine s m a
- type Handler s m a = Monad m => Webmachine s m a
- data Request m = Request {
- requestMethod :: Method
- httpVersion :: HttpVersion
- rawPathInfo :: ByteString
- rawQueryString :: ByteString
- requestHeaders :: RequestHeaders
- isSecure :: Bool
- remoteHost :: SockAddr
- pathInfo :: [Text]
- queryString :: Query
- requestBody :: m ByteString
- requestBodyLength :: RequestBodyLength
- requestHeaderHost :: Maybe ByteString
- requestHeaderRange :: Maybe ByteString
- data Response m = Response {}
- data ResponseState s m = ResponseState {
- stateUser :: s
- stateHeaders :: ResponseHeaders
- stateBody :: ResponseBody m
- _params :: HashMap Text Text
- data ResponseBody m
- = ResponseFile FilePath (Maybe FilePart)
- | ResponseBuilder Builder
- | ResponseStream (StreamingBody m)
- | Empty
- defaultRequest :: Monad m => Request m
- entireRequestBody :: Monad m => Request m -> m ByteString
- etagToByteString :: ETag -> ByteString
- eitherResponse :: Monad m => UTCTime -> HashMap Text Text -> Request m -> s -> Handler s m (Response m) -> m (Response m, Trace)
- escapedResponse :: Text -> ResponseBody m
- runWebmachine :: Monad m => UTCTime -> HashMap Text Text -> Request m -> s -> Handler s m a -> m (Either (Response m) a, Trace)
- request :: Handler s m (Request m)
- requestTime :: Handler s m UTCTime
- getState :: Handler s m s
- putState :: s -> Handler s m ()
- modifyState :: (s -> s) -> Handler s m ()
- getResponseHeaders :: Handler s m ResponseHeaders
- getResponseBody :: Handler s m (ResponseBody m)
- params :: Handler s m (HashMap Text Text)
- putResponseBody :: ResponseBody m -> Handler s m ()
- putResponseBS :: ByteString -> Handler s m ()
- halt :: Status -> Handler m s a
- finishWith :: Response m -> Handler s m a
- (#>) :: MonadWriter [(k, v)] m => k -> v -> m ()
Documentation
data Webmachine s m a Source
MonadBase b m => MonadBase b (Webmachine s m) | |
MonadBaseControl b m => MonadBaseControl b (Webmachine s m) | |
MonadTrans (Webmachine s) | |
Monad m => Monad (Webmachine s m) | |
Monad m => Functor (Webmachine s m) | |
Monad m => Applicative (Webmachine s m) | |
MonadIO m => MonadIO (Webmachine s m) | |
Monad m => MonadState (ResponseState s m) (Webmachine s m) | |
type StM (Webmachine s m) a |
type Handler s m a = Monad m => Webmachine s m a Source
A convenience synonym that writes the Monad
type constraint for you.
Very similar to WAI's Request
type, except generalized to an arbitrary monad m
.
Request | |
|
data ResponseState s m Source
ResponseState | |
|
Monad m => MonadState (ResponseState s m) (Webmachine s m) |
data ResponseBody m Source
Basically Wai's unexported Response
type, but generalized to any monad,
m
.
ResponseFile FilePath (Maybe FilePart) | |
ResponseBuilder Builder | |
ResponseStream (StreamingBody m) | |
Empty |
defaultRequest :: Monad m => Request m Source
entireRequestBody :: Monad m => Request m -> m ByteString Source
Reads the entirety of the request body in a single string.
This turns the chunks obtained from repeated invocations of requestBody
into a lazy ByteString
.
etagToByteString :: ETag -> ByteString Source
eitherResponse :: Monad m => UTCTime -> HashMap Text Text -> Request m -> s -> Handler s m (Response m) -> m (Response m, Trace) Source
escapedResponse :: Text -> ResponseBody m Source
Helper function for building a ResponseBuilder
out of HTML-escaped text.
runWebmachine :: Monad m => UTCTime -> HashMap Text Text -> Request m -> s -> Handler s m a -> m (Either (Response m) a, Trace) Source
requestTime :: Handler s m UTCTime Source
Returns the time at which this request began processing.
modifyState :: (s -> s) -> Handler s m () Source
Applies the provided function to the user state.
getResponseHeaders :: Handler s m ResponseHeaders Source
Returns the ResponseHeaders
stored in the current Handler
.
getResponseBody :: Handler s m (ResponseBody m) Source
Returns the current ResponseBody
that this Handler
is storing.
params :: Handler s m (HashMap Text Text) Source
Returns the bound routing parameters extracted from the routing system (see Airship.Route).
putResponseBody :: ResponseBody m -> Handler s m () Source
Given a new ResponseBody
, replaces the stored body with the new one.
putResponseBS :: ByteString -> Handler s m () Source
Stores the provided ByteString
as the responseBody. This is a shortcut for
creating a response body with a ResponseBuilder
and a bytestring Builder
.
halt :: Status -> Handler m s a Source
Immediately halts processing with the provided Status
code.
The contents of the Handler'
s response body will be streamed back to the client.
This is a shortcut for constructing a Response
with getResponseHeaders
and getResponseBody
and passing that response to finishWith
.
finishWith :: Response m -> Handler s m a Source
Immediately halts processing and writes the provided Response
back to the client.
(#>) :: MonadWriter [(k, v)] m => k -> v -> m () Source
The #>
operator provides syntactic sugar for the construction of association lists.
For example, the following assoc list:
[("run", "jewels"), ("blue", "suede"), ("zion", "wolf")]
can be represented as such:
execWriter $ do "run" #> "jewels" "blue" #> "suede" "zion" #> "wolf"
It used in RoutingSpec
declarations to indicate that a particular Route
maps
to a given Resource
, but can be used in many other places where association lists
are expected, such as contentTypesProvided
.