gemini-router-0.1.1.0: A simple Happstack-style Gemini router
Safe HaskellNone
LanguageHaskell2010

Network.Gemini.Router

Synopsis

The Route monad transformer

data RouteT m a Source #

Represents a way of routing requests through different handlers

Instances

Instances details
MonadTrans RouteT Source # 
Instance details

Defined in Network.Gemini.Router

Methods

lift :: Monad m => m a -> RouteT m a #

Monad m => Monad (RouteT m) Source # 
Instance details

Defined in Network.Gemini.Router

Methods

(>>=) :: RouteT m a -> (a -> RouteT m b) -> RouteT m b #

(>>) :: RouteT m a -> RouteT m b -> RouteT m b #

return :: a -> RouteT m a #

Functor f => Functor (RouteT f) Source # 
Instance details

Defined in Network.Gemini.Router

Methods

fmap :: (a -> b) -> RouteT f a -> RouteT f b #

(<$) :: a -> RouteT f b -> RouteT f a #

Monad m => MonadFail (RouteT m) Source # 
Instance details

Defined in Network.Gemini.Router

Methods

fail :: String -> RouteT m a #

Applicative f => Applicative (RouteT f) Source # 
Instance details

Defined in Network.Gemini.Router

Methods

pure :: a -> RouteT f a #

(<*>) :: RouteT f (a -> b) -> RouteT f a -> RouteT f b #

liftA2 :: (a -> b -> c) -> RouteT f a -> RouteT f b -> RouteT f c #

(*>) :: RouteT f a -> RouteT f b -> RouteT f b #

(<*) :: RouteT f a -> RouteT f b -> RouteT f a #

MonadIO m => MonadIO (RouteT m) Source # 
Instance details

Defined in Network.Gemini.Router

Methods

liftIO :: IO a -> RouteT m a #

Monad f => Alternative (RouteT f) Source #

empty skips to the next route. r1 <|> r2 means go to r2 if r1 skips

Instance details

Defined in Network.Gemini.Router

Methods

empty :: RouteT f a #

(<|>) :: RouteT f a -> RouteT f a -> RouteT f a #

some :: RouteT f a -> RouteT f [a] #

many :: RouteT f a -> RouteT f [a] #

Running Routes

runRouteT :: RouteT m a -> Request -> [String] -> m (Maybe a) Source #

runRouteT' Source #

Arguments

:: (m (Maybe Response) -> IO (Maybe Response))

Inner run

-> RouteT m Response 
-> Handler 

Given a run function for the inner Monad, make a Handler

Building Routes

end Source #

Arguments

:: Applicative f 
=> RouteT f a

Route to run

-> RouteT f a 

Match on the end of the path

dir Source #

Arguments

:: 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

capture Source #

Arguments

:: 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

input Source #

Arguments

:: 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

optionalInput Source #

Arguments

:: 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

cert Source #

Arguments

:: 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

optionalCert Source #

Arguments

:: 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