|
| Network.UrlDisp | | Portability | portable | | Stability | experimental | | Maintainer | artyom.shalkhakov@gmail.com |
|
|
|
|
|
| Description |
| URL dispatching (routing) library, based on Sterling Clover's HVAC.
|
|
| Synopsis |
|
| type UrlDisp m a = StateT UrlS (MaybeT m) a | | | data UrlS | | | h :: MonadCGI m => m () | | | (|/) :: (MonadState UrlS m, Alternative m) => m a -> String -> m () | | | (|//) :: (MonadCGI m, Alternative m) => m a -> String -> m () | | | (|?) :: (MonadCGI 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 | | | path :: (MonadState UrlS m, Alternative m) => String -> m () | | | meth :: (MonadCGI m, Alternative m) => String -> m () | | | param :: (MonadCGI 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 () | | | runUrlDisp :: MonadCGI m => String -> UrlDisp m a -> m (Maybe a) | | | evalUrlDisp :: (MonadCGI m, MonadIO m) => UrlDisp m CGIResult -> m CGIResult |
|
|
|
| Types
|
|
|
|
|
Instances | |
|
|
| Controller combinators
|
|
|
| A null CGI action, used to begin a string of path combinators
|
|
|
| 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.
|
|
|
| Combinator that filters on the request method.
h |// "GET" will match requests made using get.
|
|
|
| Combinator that filters on any parameter (via put or get).
h |? ("cmd","foo") will match on ?cmd=foo
|
|
|
| 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.
|
|
|
| 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.
|
|
|
| Combinator that only matches if the remaining path is empty.
|
|
|
| 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.
|
|
|
| Filters on the request method.
meth "GET" will match requests made using get.
|
|
|
| Filters on any parameter (via put or get).
param ("cmd", "foo") will match on ?cmd=foo
|
|
|
| Combinator that consumes the next element of the path and passes it
as an unparsed string into the following lambda expression.
h takePath \x -> output (x++"99") will match on "/12" and
output "1299"
Consumption of the path element backtracks on failure.
|
|
|
| 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.
|
|
|
| Only matches if the remaining path is empty.
|
|
| Running UrlDisp
|
|
|
| :: MonadCGI m | | | => String | | | -> UrlDisp m a | | | -> m (Maybe a) | | | Given path and a sequence of actions chained using combinators
defined in controller API, run them in the CGI monad.
|
|
|
|
| The same as runUrlDisp, but yields CGIResult. If URL dispatching
failed, then a 404 not found error is returned.
|
|
| Produced by Haddock version 2.6.0 |