Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.Wai.Routing.Purescheme.Core.Basic
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
- withIO :: IO a -> (a -> GenericApplication b) -> GenericApplication b
Documentation
type GenericApplication r = Request -> (r -> IO ResponseReceived) -> IO ResponseReceived Source #
Abstraction of Wai @Application
on the type of response
Constructors
Rejection | |
Instances
Show Rejection Source # | |
Exception Rejection Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Internal Methods toException :: Rejection -> SomeException # fromException :: SomeException -> Maybe Rejection # displayException :: Rejection -> String # |
class FromUri a where Source #
Class of types that can be converted from the uri
Minimal complete definition
Instances
FromUri Bool Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic | |
FromUri Int Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic | |
FromUri Int32 Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic | |
FromUri Int64 Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic | |
FromUri Text Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic | |
FromUri Text Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic |
class HasResponseHeaders a where Source #
Class which instaances contains response heaaders
Methods
mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> a -> a Source #
Instances
HasResponseHeaders Response Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Basic Methods mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> Response -> Response Source # | |
HasResponseHeaders NegotiatedResponse Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Entity Methods mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> NegotiatedResponse -> NegotiatedResponse Source # | |
HasResponseHeaders (EntityResponse a) Source # | |
Defined in Network.Wai.Routing.Purescheme.Core.Entity Methods mapResponseHeaders :: (ResponseHeaders -> ResponseHeaders) -> EntityResponse a -> EntityResponse a Source # |
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