Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type GenericApplication r = Request -> (r -> IO ResponseReceived) -> IO ResponseReceived
- data Rejection = Rejection {}
- class FromUri a where
- fromText :: Text -> a
- fromByteString :: ByteString -> a
- class HasResponseHeaders a where
- mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> a -> a
- alternatives :: [GenericApplication r] -> GenericApplication r
- handleException :: Exception e => (e -> GenericApplication a) -> GenericApplication a -> GenericApplication a
- withDefaultExceptionHandler :: GenericApplication Response -> GenericApplication Response
- complete :: a -> GenericApplication a
- completeIO :: IO a -> GenericApplication a
- mapResponse :: (a -> b) -> GenericApplication a -> GenericApplication b
- withRequest :: (Request -> GenericApplication a) -> GenericApplication a
Documentation
type GenericApplication r = Request -> (r -> IO ResponseReceived) -> IO ResponseReceived Source #
Abstraction of Wai @Application
on the type of response
Instances
class FromUri a where Source #
Class of types that can be converted from the uri
fromText :: Text -> a Source #
fromByteString :: ByteString -> a Source #
Instances
FromUri Bool Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text -> Bool Source # fromByteString :: ByteString -> Bool Source # | |
FromUri Int Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text -> Int Source # fromByteString :: ByteString -> Int Source # | |
FromUri Int32 Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text -> Int32 Source # fromByteString :: ByteString -> Int32 Source # | |
FromUri Int64 Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text -> Int64 Source # fromByteString :: ByteString -> Int64 Source # | |
FromUri Text Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text -> Text Source # fromByteString :: ByteString -> Text Source # | |
FromUri Text Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic fromText :: Text0 -> Text Source # fromByteString :: ByteString -> Text Source # |
class HasResponseHeaders a where Source #
Class which instaances contains response heaaders
mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> a -> a Source #
Instances
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