coltrane-0.1.0.0: A jazzy, minimal web framework for Haskell, inspired by Sinatra.

Safe HaskellNone

Coltrane

Synopsis

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.

htmlFile :: FilePath -> IO StringSource

Reads a file in as a String.

setBody :: ContentType -> ResponseBody -> HandlerM ()Source

Set the current ResponseState's body, and add the corresponding content type header

setStatus :: Status -> HandlerM ()Source

Set the current ResponseState's status

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.

request :: HandlerM RequestSource

Retrieve the current request object

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.