wai-routes-0.7.2: Typesafe URLs for Wai applications.

Copyright(c) Anupam Jain 2013
LicenseMIT (see the file LICENSE)
Maintainerajnsit@gmail.com
Stabilityexperimental
Portabilitynon-portable (uses ghc extensions)
Safe HaskellNone
LanguageHaskell2010

Network.Wai.Middleware.Routes.Handler

Description

Provides a HandlerM Monad that makes it easy to build Handlers

Synopsis

Documentation

type HandlerM sub master a = HandlerMI sub master IO a Source

The HandlerM Monad

A Monad that makes it easier to build a Handler

runHandlerM :: HandlerM sub master () -> HandlerS sub master Source

Run HandlerM, resulting in a Handler

Run a HandlerM to get a Handler

request :: HandlerM sub master Request Source

Get the request

Access the request data

routeAttrSet :: RouteAttrs sub => HandlerM sub master (Set Text) Source

Get the current route attributes

Access the route attribute list

rootRouteAttrSet :: RouteAttrs master => HandlerM sub master (Set Text) Source

Get the attributes for the current root route

Access the route attribute list for the root route

maybeRoute :: HandlerM sub master (Maybe (Route sub)) Source

Get the current route

Access the route data

maybeRootRoute :: HandlerM sub master (Maybe (Route master)) Source

Get the current root route

Access the root route data

master :: HandlerM sub master master Source

Get the master

Access the master datatype

header :: HeaderName -> ByteString -> HandlerM sub master () Source

Add a header to the application response TODO: Differentiate between setting and adding headers

Add a header to the response

status :: Status -> HandlerM sub master () Source

Set the response status

Set the response status

file :: FilePath -> HandlerM sub master () Source

Set the response body to a file

Send a file as response

raw :: ByteString -> HandlerM sub master () Source

Set the response body TODO: Add functions to append to body, and also to flush body contents

Set the raw response body

json :: ToJSON a => a -> HandlerM sub master () Source

Set the body of the response to the JSON encoding of the given value. Also sets "Content-Type" header to "application/json".

Set the json response body

plain :: Text -> HandlerM sub master () Source

Set the body of the response to the given Text value. Also sets "Content-Type" header to "text/plain".

Set the plain text response body

html :: Text -> HandlerM sub master () Source

Set the body of the response to the given Text value. Also sets "Content-Type" header to "text/html".

Set the html response body

next :: HandlerM sub master () Source

Run the next application

Run the next application in the stack

rawBody :: HandlerM master master ByteString Source

Get the request body as a lazy bytestring Get the body as a Lazy bytestring EXPERIMENTAL. Consumes the entire body TODO: Implement streaming. Prevent clash with direct use of requestBody

Consume and return the request body as a lazy bytestring

jsonBody :: FromJSON a => HandlerM master master (Either String a) Source

Consume and return the request body as JSON