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

Portabilitynon-portable (uses ghc extensions)
Stabilityexperimental
Maintainerajnsit@gmail.com
Safe HaskellNone

Network.Wai.Middleware.Routes.Handler

Description

Provides a HandlerM Monad that makes it easy to build Handlers

Synopsis

Documentation

type HandlerM master a = HandlerMI master IO aSource

The HandlerM Monad

A Monad that makes it easier to build a Handler

runHandlerM :: HandlerM master () -> Handler masterSource

Run HandlerM, resulting in a Handler

Run a HandlerM to get a Handler

request :: HandlerM master RequestSource

Get the request

Access the request data

master :: HandlerM master masterSource

Get the master

Access the master datatype

header :: HeaderName -> ByteString -> HandlerM 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 master ()Source

Set the response status

Set the response status

raw :: ByteString -> HandlerM 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 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

text :: Text -> HandlerM master ()Source

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

Set the text response body

html :: ByteString -> HandlerM 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 master ()Source

Run the next application

Run the next application in the stack