Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
Route
s represent chunks of text used to match over URLs.
You match hardcoded paths with string literals (and the -XOverloadedStrings
extension),
named variables with the var
combinator, and wildcards with star
.
Show Route | |
IsString Route | |
Monoid Route | |
MonadWriter [(Route, Resource s m)] (RoutingSpec s m) |
data RoutingSpec s m a Source
Represents a fully-specified set of routes that map paths (represented as Route
s) to Resource
s. RoutingSpec
s are declared with do-notation, to wit:
myRoutes :: RoutingSpec MyState IO () myRoutes = do root #> myRootResource "blog"</>
var "date"</>
var "post" #> blogPostResource "about" #> aboutResource "anything"</>
star #> wildcardResource
MonadWriter [(Route, Resource s m)] (RoutingSpec s m) | |
Monad (RoutingSpec s m) | |
Functor (RoutingSpec s m) | |
Applicative (RoutingSpec s m) |
Represents the root resource (/
). This should usually be the first path declared in a RoutingSpec
.
Captures a wildcard route. For example,
"emcees" </>
star
will match /emcees
, /emcees/biggie
, /emcees/earl/vince
, and so on and so forth.
(#>) :: MonadWriter [(k, v)] m => k -> v -> m () Source
The #>
operator provides syntactic sugar for the construction of association lists.
For example, the following assoc list:
[("run", "jewels"), ("blue", "suede"), ("zion", "wolf")]
can be represented as such:
execWriter $ do "run" #> "jewels" "blue" #> "suede" "zion" #> "wolf"
It used in RoutingSpec
declarations to indicate that a particular Route
maps
to a given Resource
, but can be used in many other places where association lists
are expected, such as contentTypesProvided
.