purescheme-wai-routing-core- Simple Routing functions for Wai Applications
Safe HaskellNone




type GenericApplication r = Request -> (r -> IO ResponseReceived) -> IO ResponseReceived Source #

Abstraction of Wai @Application on the type of response

alternatives :: [GenericApplication r] -> GenericApplication r Source #

Combines multiple generic applications in one This function will try every application for each request, and return the first response that does not fail

In case of rejections (Reection thrown), it will rethrown the first exception with higher priority

handleException :: Exception e => (e -> GenericApplication a) -> GenericApplication a -> GenericApplication a Source #

Capture exceptions and convert to generic applications

withDefaultExceptionHandler :: GenericApplication Response -> GenericApplication Response Source #

By default capture all @Rejection and convert them in specific responses the content type returned is 'text/plain" and the body will contain the error message

complete :: a -> GenericApplication a Source #

Ends the request responding with the argument

completeIO :: IO a -> GenericApplication a Source #

Ends the request excuting the provided IO and responding the result of the IO

mapResponse :: (a -> b) -> GenericApplication a -> GenericApplication b Source #

Maps a response type to another response type

withRequest :: (Request -> GenericApplication a) -> GenericApplication a Source #

Pass the request to the provided function

withIO :: IO a -> (a -> GenericApplication b) -> GenericApplication b Source #

Execute an IO Action and pass it to the provided function