| Safe Haskell | None |
|---|
Happstack.StaticRouting
Description
Support for static routing tables in Happstack. The routing tables are order independent as long as:
- if any two handlers overlap, one of them handles a more specific path than the other. The more specific handler is then tried first.
Routing tables are constructed from dir, path, remainingPath,
choice, and (for now) param.
A routing table is compiled by using compile. The result is an
overlap report, and a prefix tree that is used to efficiently
dispatch requests by means of dispatch.
See the file src/Happstack/StaticRouting/Test.hs in the distribution
for examples.
- data Route a
- compile :: (MonadIO m, HasRqData m, ServerMonad m, MonadPlus m) => Route (m a) -> (m a, Maybe String)
- choice :: [Route a] -> Route a
- dir :: String -> Route a -> Route a
- path :: Path m h a => Method -> (m a -> m b) -> h -> Route (m b)
- class Path m a b | a -> m b
- remainingPath :: Method -> h -> Route h
- param :: String -> Route a -> Route a
Documentation
compile :: (MonadIO m, HasRqData m, ServerMonad m, MonadPlus m) => Route (m a) -> (m a, Maybe String)Source
Compile routes, also return possible overlap report. If the
overlap report is Nothing, the routing table is order
independent. If the overlap report is Just s, then s is a
textual representation of all the paths that are order dependent,
suitable for a warning message.
path :: Path m h a => Method -> (m a -> m b) -> h -> Route (m b)Source
Expect the given method, and exactly n more segments, where n is the arity of the handler.
class Path m a b | a -> m bSource
Support for varying number of arguments to path handlers.
Instances
| Path m (m b) b | |
| (FromReqURI d, ServerMonad m, MonadPlus m, Path m a b) => Path m (d -> a) b |
remainingPath :: Method -> h -> Route hSource
Expect zero or more segments.