Liking cljdoc? Tell your friends :D

calfpath.route


*routes*clj

source

assoc-kv-middlewareclj

(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.
sourceraw docstring

compile-routesclj

(compile-routes route-specs)
(compile-routes route-specs
                {:keys [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 {full-uri-key :full-uri
                      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: :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:
 :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
sourceraw docstring

conj-fallback-400clj

(conj-fallback-400 routes)
(conj-fallback-400 routes {:keys [show-uris? uri-finder uri-prefix] :as opts})
source

conj-fallback-405clj

(conj-fallback-405 routes {:keys [allowed-methods method-finder] :as opts})
source

conj-fallback-matchclj

(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.
sourceraw docstring

dispatchclj

(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}

  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.
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.
sourceraw docstring

ensure-matchexclj

(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.
sourceraw docstring

lift-key-middlewareclj

(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.
sourceraw docstring

make-dispatcherclj

(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}

  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.
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.
sourceraw docstring

make-ensurerclj

(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.
sourceraw docstring

make-method-matcherclj

(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.
sourceraw docstring

make-updaterclj

(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.
sourceraw docstring

make-uri-matcherclj

(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.
sourceraw docstring

prewalk-routesclj

(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.
sourceraw docstring

trailing-slash-middlewareclj

(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.
sourceraw docstring

update-each-routeclj

(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.
sourceraw docstring

update-fallback-400clj

(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.
sourceraw docstring

update-fallback-405clj

(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.
sourceraw docstring

update-in-each-routeclj

(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.
sourceraw docstring

update-routesclj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close