(clear-routes!)
Clears the global set of defined-routes
.
Clears the global set of [[defined-routes]].
An atom with a set of all routes created by defroute
since the last call to clear-routes!
.
An atom with a set of all routes created by [[defroute]] since the last call to [[clear-routes!]].
(defroute name pattern)
Defines a var with the given name
to be a route according the given pattern
, and adds it to the global set of defined-routes
.
A pattern can be a fixed path "/path/to/page"
, or can have one or more path arguments "/article/:id"
.
For example:
(defroute r0 "/home")
(href r0) => "/home"
(parse r0 "/home") => []
(href r0 {:lang "de"}) => "/home?lang=de"
(parse r0 "/home?lang=de") => [{:lang "de"}]
(defroute r1 "/path/:id")
(href r1 "123") => "/path/123"
(parse r1 "/path/123") => ["123"]
(parse r1 "/other/path") => nil
Defines a var with the given `name` to be a route according the given `pattern`, and adds it to the global set of [[defined-routes]]. A pattern can be a fixed path `"/path/to/page"`, or can have one or more path arguments `"/article/:id"`. For example: ```clojure (defroute r0 "/home") (href r0) => "/home" (parse r0 "/home") => [] (href r0 {:lang "de"}) => "/home?lang=de" (parse r0 "/home?lang=de") => [{:lang "de"}] (defroute r1 "/path/:id") (href r1 "123") => "/path/123" (parse r1 "/path/123") => ["123"] (parse r1 "/other/path") => nil ```
(href route & params)
Returns a relative URI for the given route and concrete values for all parameters. The last parameter may be a map of query params.
Returns a relative URI for the given route and concrete values for all parameters. The last parameter may be a map of query params.
(parse route uri)
If the given URI matches the given route, returns a vector of all path arguments and optionally a map of query params.
If the given URI matches the given route, returns a vector of all path arguments and optionally a map of query params.
(routable? v)
If v
is a value returned by [[route]] of bound to a name with defroute
.
If `v` is a value returned by [[route]] of bound to a name with [[defroute]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close