(defroute name pattern)
Defines a var with the given name
to be a route according the given pattern
.
Adds it to the a list of routes, if written inside a defroutes
macro.
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") => []
(r0 {:lang "de"}) => "/home?lang=de"
(parse r0 "/home?lang=de") => [{:lang "de"}]
(defroute r1 "/path/:id")
(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`. Adds it to the a list of routes, if written inside a [[defroutes]] macro. 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") => [] (r0 {:lang "de"}) => "/home?lang=de" (parse r0 "/home?lang=de") => [{:lang "de"}] (defroute r1 "/path/:id") (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