(assoc-kv-middleware spec main-key-finder assoc-map)
Given a route spec, if the route contains the main key then ensure that it also has the associated key/value pairs.
Given a route spec, if the route contains the main key then ensure that it also has the associated key/value pairs.
(assoc-route-to-request-middleware spec)
(assoc-route-to-request-middleware spec spec-key)
Given a route spec, decorate the handler such that the request has the spec under specified key (:route by default) at runtime.
Given a route spec, decorate the handler such that the request has the spec under specified key (:route by default) at runtime.
(compile-routes route-specs)
(compile-routes route-specs
{:keys [trie? trie-threshold uri? uri-key fallback-400?
show-uris-400? full-uri-key uri-prefix-400 params-key
method? method-key fallback-405? trailing-slash
lift-uri? ring-handler? ring-handler-key]
:or {trie? true
full-uri-key :full-uri
trie-threshold 1
method? true
trailing-slash false
method-key :method
uri? true
fallback-405? true
lift-uri? true
show-uris-400? true
fallback-400? true
uri-key :uri}
:as options})
Given a collection of route specs, supplement them with required entries and finally return a routes collection. Options: :trie? (boolean) optimize routes by automatically reorganizing routes as tries :trie-threshold (integer) similar routes more than this number will be grouped together :uri? (boolean) true if URI templates should be converted to matchers :uri-key (non-nil) the key to be used to look up the URI template in a spec :params-key (any) the key to put URI params under; if nil (default), params map is merged into request :trailing-slash (keyword) Trailing-slash action to perform on URIs - :add or :remove - nil (default) has no effect :fallback-400? (boolean) whether to add a fallback route to respond with HTTP status 400 for unmatched URIs :show-uris-400? (boolean) whether to add URI templates in the HTTP 400 response (see :fallback-400?) :full-uri-key (non-nil) the key to be used to populate full-uri for reporting HTTP 400 (see :show-uris-400?) :uri-prefix-400 (string?) the URI prefix to use when showing URI templates in HTTP 400 (see :show-uris-400?) :method? (boolean) true if HTTP methods should be converted to matchers :method-key (non-nil) the key to be used to look up the method key/set in a spec :fallback-405? (boolean) whether to add a fallback route to respond with HTTP status 405 for unmatched methods :lift-uri? (boolean) whether lift URI attributes from mixed specs and move the rest into nested specs
Given a collection of route specs, supplement them with required entries and finally return a routes collection. Options: :trie? (boolean) optimize routes by automatically reorganizing routes as tries :trie-threshold (integer) similar routes more than this number will be grouped together :uri? (boolean) true if URI templates should be converted to matchers :uri-key (non-nil) the key to be used to look up the URI template in a spec :params-key (any) the key to put URI params under; if nil (default), params map is merged into request :trailing-slash (keyword) Trailing-slash action to perform on URIs - :add or :remove - nil (default) has no effect :fallback-400? (boolean) whether to add a fallback route to respond with HTTP status 400 for unmatched URIs :show-uris-400? (boolean) whether to add URI templates in the HTTP 400 response (see :fallback-400?) :full-uri-key (non-nil) the key to be used to populate full-uri for reporting HTTP 400 (see :show-uris-400?) :uri-prefix-400 (string?) the URI prefix to use when showing URI templates in HTTP 400 (see :show-uris-400?) :method? (boolean) true if HTTP methods should be converted to matchers :method-key (non-nil) the key to be used to look up the method key/set in a spec :fallback-405? (boolean) whether to add a fallback route to respond with HTTP status 405 for unmatched methods :lift-uri? (boolean) whether lift URI attributes from mixed specs and move the rest into nested specs
(conj-fallback-400 routes)
(conj-fallback-400 routes {:keys [show-uris? uri-finder uri-prefix] :as opts})
(conj-fallback-405 routes {:keys [allowed-methods method-finder] :as opts})
(conj-fallback-match routes handler)
Given a route vector append a matcher that always matches with a corresponding specified handler.
Given a route vector append a matcher that always matches with a corresponding specified handler.
(dispatch routes request)
(dispatch routes request f)
(dispatch routes request respond raise)
Given a vector of routes, recursively walk the routes evaluating the specified Ring request with each matcher.
Invoke corresponding handler on successful match.
Synopsis:
0. A route is a map {:matcher (fn [request]) -> request?
; :matcher is a required key
:nested vector of child routes ; either :handler or :nested key must be present
:handler Ring handler for route}
Given a vector of routes, recursively walk the routes evaluating the specified Ring request with each matcher. Invoke corresponding handler on successful match. Synopsis: 0. A route is a map {:matcher `(fn [request]) -> request?` ; :matcher is a required key :nested vector of child routes ; either :handler or :nested key must be present :handler Ring handler for route} 1. A matcher is (fn [request]) that returns a potentially-updated request on successful match, nil otherwise. 2. Handler is a Ring handler (fn [request] [request respond raise]) that responds to a Ring request.
(ensure-matchex route-spec matchex)
Given a route spec not containing the :matchex key, assoc specified matchex into the spec. If the route spec already contains :matchex then leave it intact.
Given a route spec not containing the :matchex key, assoc specified matchex into the spec. If the route spec already contains :matchex then leave it intact.
(lift-key-middleware spec lift-keys conflict-keys)
Given a route spec, lift keys and one or more conflict keys, if the spec contains both any of the lift-keys and any of the conflict-keys then extract the lift keys such that all other attributes are moved into a nested spec.
Given a route spec, lift keys and one or more conflict keys, if the spec contains both any of the lift-keys and any of the conflict-keys then extract the lift keys such that all other attributes are moved into a nested spec.
(make-dispatcher routes)
Given a collection of routes return a Ring handler function that matches specified request and invokes
corresponding route handler on successful match, returns nil otherwise.
Synopsis:
0. A route is a map {:matcher (fn [request]) -> request?
; :matcher is a required key
:matchex (fn [request-sym]) -> matcher
; optional (enabled by default)
:nested routes-vector ; either :handler or :nested key must be present
:handler Ring handler}
Given a collection of routes return a Ring handler function that matches specified request and invokes corresponding route handler on successful match, returns nil otherwise. Synopsis: 0. A route is a map {:matcher `(fn [request]) -> request?` ; :matcher is a required key :matchex `(fn [request-sym]) -> matcher` ; optional (enabled by default) :nested routes-vector ; either :handler or :nested key must be present :handler Ring handler} 1. A matcher is (fn [request]) that returns a potentially-updated request on successful match, nil otherwise. 2. A matchex is (fn [request-sym]) that returns expression to eval instead of calling matcher. The matchex is used only when :matcher is also present. Expr should return a value similar to matcher. 3. A matchex is for optimization only, which may be disabled by setting a false or nil value for the :matchex key. 4. Handler is a Ring handler (fn [request] [request respond raise]) that responds to a Ring request.
(make-ensurer k f)
Given a key and factory fn (accepts route and other args, returns new route), create a route updater fn that applies f to the route only when it does not contain the key.
Given a key and factory fn (accepts route and other args, returns new route), create a route updater fn that applies f to the route only when it does not contain the key.
(make-index routes)
(make-index routes options)
Given a collection of routes, index them returning a map {:id route-template}.
Given a collection of routes, index them returning a map {:id route-template}.
(make-method-matcher route-spec method-finder)
Given a route spec not containing the :matcher key and containing HTTP-method keyword (or keyword set) as value (found by method-finder), create a method matcher and add it under the :matcher key. If the route spec already contains the :matcher key or if it does not contain HTTP-method keyword/set then the route spec is left intact. When adding matcher also add matchex unless the :matchex key already exists.
Given a route spec not containing the :matcher key and containing HTTP-method keyword (or keyword set) as value (found by method-finder), create a method matcher and add it under the :matcher key. If the route spec already contains the :matcher key or if it does not contain HTTP-method keyword/set then the route spec is left intact. When adding matcher also add matchex unless the :matchex key already exists.
(make-updater k f)
Given a key and updater fn (accepts route and other args, returns new route), create a route updater fn that applies f to the route only when it contains the key.
Given a key and updater fn (accepts route and other args, returns new route), create a route updater fn that applies f to the route only when it contains the key.
(make-uri-matcher route-spec uri-finder params-key)
Given a route spec not containing the :matcher key and containing URI-pattern string as value (found by uri-finder), create a URI matcher and add it under the :matcher key. If the route spec already contains the :matcher key or if it does not contain URI-pattern then the route spec is left intact. When adding matcher also add matchex unless the :matchex key already exists.
Given a route spec not containing the :matcher key and containing URI-pattern string as value (found by uri-finder), create a URI matcher and add it under the :matcher key. If the route spec already contains the :matcher key or if it does not contain URI-pattern then the route spec is left intact. When adding matcher also add matchex unless the :matchex key already exists.
(prewalk-routes routes parent-route f & args)
Given a bunch of routes, update every route (recursively) with f, which receives parent route as second arg.
Given a bunch of routes, update every route (recursively) with f, which receives parent route as second arg.
(realize-uri uri-template uri-params)
Given a vector of the form ['/users' :user-id '/profile/' :profile '/'] fill in the param values returning a URI.
Given a vector of the form ['/users' :user-id '/profile/' :profile '/'] fill in the param values returning a URI.
(routes->wildcard-trie routes)
(routes->wildcard-trie routes
{:keys [trie-threshold uri-key]
:or {trie-threshold 1 uri-key :uri}
:as options})
Given a bunch of routes, segment them by prefix URI-tokens into a trie-like structure for faster match.
Given a bunch of routes, segment them by prefix URI-tokens into a trie-like structure for faster match.
(template->request request-template uri-params)
Given a request template, realize the attributes to create a minimal Ring request.
Given a request template, realize the attributes to create a minimal Ring request.
(trailing-slash-middleware spec uri-key action)
Given a route spec, URI key and action (keyword :add or :remove) edit the URI to have or not have a trailing slash if the route has a URI pattern. Leave the route unchanged if it has no URI pattern.
Given a route spec, URI key and action (keyword :add or :remove) edit the URI to have or not have a trailing slash if the route has a URI pattern. Leave the route unchanged if it has no URI pattern.
(update-each-route routes f & args)
Given a bunch of routes, update every route (recursively) with f.
Given a bunch of routes, update every route (recursively) with f.
(update-fallback-400 routes)
(update-fallback-400 routes uri-finder opts)
Update routes by appending a fallback HTTP-400 route only when all routes have :uri key.
Update routes by appending a fallback HTTP-400 route only when all routes have :uri key.
(update-fallback-405 routes method-finder)
(update-fallback-405 routes method-finder opts)
Update routes by appending a fallback HTTP-405 route when all routes have :method key.
Update routes by appending a fallback HTTP-405 route when all routes have :method key.
(update-in-each-route specs reference-key f)
Given a bunch of routes, update every route (recursively) containing specified attribute with the given wrapper. The wrapper fn f is invoked with the old attribute value, and the returned value is updated into the route.
Given a bunch of routes, update every route (recursively) containing specified attribute with the given wrapper. The wrapper fn f is invoked with the old attribute value, and the returned value is updated into the route.
(update-routes routes f & args)
Given a bunch of routes, update every route-collection (recursively) with f.
Given a bunch of routes, update every route-collection (recursively) with f.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close