- runUrlDisp :: ServerMonad m => UrlDisp m a -> m a
- path :: (MonadState UrlS m, Alternative m) => String -> m ()
- meth :: (ServerMonad m, MonadPlus m) => String -> m ()
- param :: (ServerMonad m, Alternative m) => (String, String) -> m ()
- takePath :: (MonadState UrlS m, Alternative m) => m String
- readPath :: (Read a, MonadState UrlS m, Alternative m) => m a
- endPath :: (MonadState UrlS m, Alternative m) => m ()
- getInput :: (ServerMonad f, Alternative f) => String -> f String
- getInputMay :: (ServerMonad f, Alternative f) => String -> f (Maybe String)
- h :: ServerMonad m => m ()
- (|/) :: (MonadState UrlS m, Alternative m) => m a -> String -> m ()
- (|//) :: (ServerMonad m, MonadPlus m) => m a -> String -> m ()
- (|?) :: (ServerMonad m, Alternative m) => m a -> (String, String) -> m ()
- (|\) :: (Read x, MonadState UrlS m, Alternative m) => m a -> (x -> m b) -> m b
- (|\\) :: (MonadState UrlS m, Alternative m) => m a -> (String -> m b) -> m b
- (|.) :: (MonadState UrlS m, Alternative m) => m a -> m b -> m b
- data UrlS = UrlS {}
- newtype UrlDisp m a = UrlDisp {}
- spCatch :: Exception e => ServerPartT IO a -> (e -> ServerPartT IO a) -> ServerPartT IO a
Run the monad
runUrlDisp :: ServerMonad m => UrlDisp m a -> m aSource
Unpacks a UrlDisp into a plain old ServerMonad. Used as a top-level wrapper.
Verbose API
path :: (MonadState UrlS m, Alternative m) => String -> m ()Source
Filters on and consumes the next element of the url path.
path "str"
will match requests whose next path element is "str"
Consumption of the path element backtracks on failure.
meth :: (ServerMonad m, MonadPlus m) => String -> m ()Source
Filters on the request method.
meth "GET"
will match requests made using get.
param :: (ServerMonad m, Alternative m) => (String, String) -> m ()Source
Filters on any parameter (via put or get).
param ("cmd", "foo")
will match on ?cmd=foo
takePath :: (MonadState UrlS m, Alternative m) => m StringSource
Combinator that consumes the next element of the path and passes it
as an unparsed string into the following lambda expression.
h
will match on "/12" and
output "1299"
Consumption of the path element backtracks on failure.
takePath
\x -> output (x++"99")
readPath :: (Read a, MonadState UrlS m, Alternative m) => m aSource
Matches and consumes the next element of the path if that element can be successfully read as the proper type. The parsed element is returned.
endPath :: (MonadState UrlS m, Alternative m) => m ()Source
Only matches if the remaining path is empty.
getInput :: (ServerMonad f, Alternative f) => String -> f StringSource
Returns a string representation of a parameter, if available. Otherwise fails.
getInputMay :: (ServerMonad f, Alternative f) => String -> f (Maybe String)Source
Returns Just a string representation of a parameter, or Nothing.
Infix API
h :: ServerMonad m => m ()Source
A null CGI action, used to begin a string of path combinators
(|/) :: (MonadState UrlS m, Alternative m) => m a -> String -> m ()Source
Combinator that filters on and consumes the next element of the url
path.
h |/ "dir" |/ "subdir"
will match "/dir/subdir".
Consumtion of the path element backtracks on failure.
(|//) :: (ServerMonad m, MonadPlus m) => m a -> String -> m ()Source
Combinator that filters on the request method.
h |// "GET"
will match requests made using get.
(|?) :: (ServerMonad m, Alternative m) => m a -> (String, String) -> m ()Source
Combinator that filters on any parameter (via put or get).
h |? ("cmd","foo")
will match on ?cmd=foo
(|\) :: (Read x, MonadState UrlS m, Alternative m) => m a -> (x -> m b) -> m bSource
Combinator that matches and consumes the next element of the path
if path element can be successfully read as the proper type and passed
to the following lambda expression.
h |\ \x -> output (x + (1.5::Float))
will match on "/12"
and output "13.5". Consumption of the path element backtracks
on failure.
(|\\) :: (MonadState UrlS m, Alternative m) => m a -> (String -> m b) -> m bSource
Combinator that consumes the next element of the path and passes it
as an unparsed string into the following lambda expression.
h |\\ \x -> output (x++"99")
will match on "/12"
and output "1299"
Consumtion of the path element backtracks on failure.
(|.) :: (MonadState UrlS m, Alternative m) => m a -> m b -> m bSource
Combinator that only matches if the remaining path is empty.
Monad m => MonadState UrlS (UrlDisp m) | |
(FilterMonad Response m, Monad m) => FilterMonad Response (StateT UrlS m) | |
Monad m => Applicative (StateT UrlS m) | |
ServerMonad m => ServerMonad (StateT UrlS m) |
MonadTrans UrlDisp | |
(FilterMonad Response m, Monad m) => FilterMonad Response (UrlDisp m) | |
Monad m => WebMonad Response (UrlDisp (ServerPartT m)) | |
Monad m => MonadState UrlS (UrlDisp m) | |
Monad m => Monad (UrlDisp m) | |
Monad m => Functor (UrlDisp m) | |
MonadPlus m => MonadPlus (UrlDisp m) | |
Monad m => Applicative (UrlDisp m) | |
(Monad m, MonadPlus m, Functor m) => Alternative (UrlDisp m) | |
ServerMonad m => ServerMonad (UrlDisp m) | |
MonadIO m => MonadIO (UrlDisp m) |
Lifted catch
spCatch :: Exception e => ServerPartT IO a -> (e -> ServerPartT IO a) -> ServerPartT IO aSource