Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RouteT m a
- type Route = RouteT Identity
- type RouteIO = RouteT IO
- runRouteT :: RouteT m a -> Request -> [String] -> m (Maybe a)
- runRouteT' :: (m (Maybe Response) -> IO (Maybe Response)) -> RouteT m Response -> Handler
- end :: Applicative f => RouteT f a -> RouteT f a
- dir :: Applicative f => String -> RouteT f a -> RouteT f a
- capture :: Applicative f => (String -> RouteT f a) -> RouteT f a
- input :: Applicative f => String -> (String -> RouteT f Response) -> RouteT f Response
- optionalInput :: Applicative f => (Maybe String -> RouteT f a) -> RouteT f a
- cert :: Applicative m => String -> (X509 -> RouteT m Response) -> RouteT m Response
- optionalCert :: Applicative m => (Maybe X509 -> RouteT m Response) -> RouteT m Response
- custom :: (Request -> [String] -> m (Maybe a)) -> RouteT m a
- getRequest :: Applicative m => RouteT m Request
- getPath :: Applicative m => RouteT m [String]
The Route monad transformer
Represents a way of routing requests through different handlers
Instances
MonadTrans RouteT Source # | |
Defined in Network.Gemini.Router | |
Monad m => Monad (RouteT m) Source # | |
Functor f => Functor (RouteT f) Source # | |
Monad m => MonadFail (RouteT m) Source # | |
Defined in Network.Gemini.Router | |
Applicative f => Applicative (RouteT f) Source # | |
MonadIO m => MonadIO (RouteT m) Source # | |
Defined in Network.Gemini.Router | |
Monad f => Alternative (RouteT f) Source # |
|
Running Routes
Building Routes
:: Applicative f | |
=> String | What the segment must match |
-> RouteT f a | Route to run on the rest of the path |
-> RouteT f a |
Match on a specific path segment
:: Applicative f | |
=> (String -> RouteT f a) | Function that takes the segment and returns the route to run on the rest of the path |
-> RouteT f a |
Match on an arbitrary path segment, and capture it
:: Applicative f | |
=> String | String to return to the client if there is no query string |
-> (String -> RouteT f Response) | Function that takes the query string and returns the route to run on the rest of the path |
-> RouteT f Response |
Require a query string, by asking the client (code 10) if necessary
:: Applicative f | |
=> (Maybe String -> RouteT f a) | Function that takes the query string (if present) and returns the route to run on the rest of the path |
-> RouteT f a |
Capture, if present, the query string
:: Applicative m | |
=> String | String to return to the client if there is no client certificate in the request |
-> (X509 -> RouteT m Response) | Function that takes the client certificate and returns the route to run on the rest of the request |
-> RouteT m Response |
Require a client certificate, returning an error (code 60) if absent
:: Applicative m | |
=> (Maybe X509 -> RouteT m Response) | Function that takes the client certificate (if present) and returns the route to run on the rest of the request |
-> RouteT m Response |
Obtain, if present, the client certificate
custom :: (Request -> [String] -> m (Maybe a)) -> RouteT m a Source #
Build custom routes. Takes a function that takes the request and the
remaining path segments and returns the result. A Nothing
makes the
request fall through to the next route
Getters
getRequest :: Applicative m => RouteT m Request Source #