Safe Haskell | None |
---|
- coltrane :: Server -> Port -> ColtraneApp () -> IO ()
- get :: Path -> Handler -> ColtraneApp ()
- post :: Path -> Handler -> ColtraneApp ()
- put :: Path -> Handler -> ColtraneApp ()
- delete :: Path -> Handler -> ColtraneApp ()
- addroute :: Route -> ColtraneApp ()
- addroutes :: [Route] -> ColtraneApp ()
- html :: ResponseBody -> HandlerM ()
- text :: ResponseBody -> HandlerM ()
- json :: ResponseBody -> HandlerM ()
- file :: ResponseBody -> HandlerM ()
- htmlFile :: FilePath -> IO String
- setBody :: ContentType -> ResponseBody -> HandlerM ()
- setStatus :: Status -> HandlerM ()
- setHeader :: HeaderName -> ByteString -> HandlerM ()
- addHeader :: HeaderName -> ByteString -> HandlerM ()
- param :: String -> HandlerM String
- request :: HandlerM Request
- throwError :: MonadError e m => forall a. e -> m a
- catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a
Documentation
coltrane :: Server -> Port -> ColtraneApp () -> IO ()Source
Run the framework with the given server on the given port and application
get :: Path -> Handler -> ColtraneApp ()Source
Helper method for adding a GET route.
post :: Path -> Handler -> ColtraneApp ()Source
Helper method for adding a POST route.
put :: Path -> Handler -> ColtraneApp ()Source
Helper method for adding a PUT route.
delete :: Path -> Handler -> ColtraneApp ()Source
Helper method for adding a DELETE route.
addroute :: Route -> ColtraneApp ()Source
Add a route to the app's state.
addroutes :: [Route] -> ColtraneApp ()Source
Add multiple routes to the app's state.
html :: ResponseBody -> HandlerM ()Source
Sets body and content type for HTML.
text :: ResponseBody -> HandlerM ()Source
Sets body and content type for Text.
json :: ResponseBody -> HandlerM ()Source
Sets body and content type for JSON.
file :: ResponseBody -> HandlerM ()Source
Sets body and content type for File.
setBody :: ContentType -> ResponseBody -> HandlerM ()Source
Set the current ResponseState's body, and add the corresponding content type header
setHeader :: HeaderName -> ByteString -> HandlerM ()Source
Lookup a header and set its value to the input string. if the header does not exist, adds a new header.
addHeader :: HeaderName -> ByteString -> HandlerM ()Source
Add a header to the current ResponseState's headers HeaderName defined in Network.HTTP.Types.Header
param :: String -> HandlerM StringSource
Retrieve a parameter parsed from the URL. if not found, search through the query fields.
throwError :: MonadError e m => forall a. e -> m a
Is used within a monadic computation to begin exception processing.
catchError :: MonadError e m => forall a. m a -> (e -> m a) -> m a
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handler
where the action
functions can call throwError
.
Note that handler
and the do-block must have the same return type.