Liking cljdoc? Tell your friends :D
Clojure only.

strojure.ring-control.handler

Functions for building Ring handler from configuration.

Functions for building Ring handler from configuration.
raw docstring

buildclj

(build handler xs)
(build handler xs {:keys [async ignored-deps]})

Returns ring handler wrapped with middleware configurations xs in direct order.

Default type of ring handler is sync handler. To produce async ring handler use either :async option or {:async true} in handler's meta.

Every middleware is a map with keys:

  • {:keys [wrap]}

    • :wrap – a function (fn [handler] new-handler) to wrap handler.
  • {:keys [enter leave]}

    • :enter — a function (fn [request] new-request) to transform request.
    • :leave – a function (fn [response request] new-response) to transform response.
  • Optional middleware keys:

    • :name – a name symbol/keyword as middleware description, also used as reference in :deps key.
    • :deps — a map of required middleware names with value :before/:after, see validate-deps.
    • :meta — middleware specific data which can be used to distinguish middlewares with same name but different options, i.e. :root-path in wrap-resource.

Maps with :wrap and :enter/:leave causes exception.

Only middlewares with :wrap can short-circuit, :enter/:leave just modify request/response.

The middlewares are applied in the order:

  • Request flows from first to last.
  • Response flows from last to first.
  • Every middleware receives request from previous :wrap/:enter middlewares only.
  • Every :leave/:wrap receives response from next middlewares.

The xs is validating for dependencies with validate-deps. The option :ignored-deps contains dependency names to ignore in validation.

Returns ring handler wrapped with middleware configurations `xs` in direct
order.

Default type of ring handler is sync handler. To produce async ring handler
use either `:async` option or `{:async true}` in handler's meta.

Every middleware is a map with keys:

- `{:keys [wrap]}`

    - `:wrap`  – a function `(fn [handler] new-handler)` to wrap handler.

- `{:keys [enter leave]}`

    - `:enter` — a function `(fn [request] new-request)` to transform request.
    - `:leave` – a function `(fn [response request] new-response)` to transform
                 response.

- Optional middleware keys:

    - `:name` – a name symbol/keyword as middleware description, also used as
                reference in `:deps` key.
    - `:deps` — a map of required middleware names with value
                `:before`/`:after`, see [[validate-deps]].
    - `:meta` — middleware specific data which can be used to distinguish
                middlewares with same name but different options, i.e.
                `:root-path` in `wrap-resource`.

Maps with `:wrap` and `:enter`/`:leave` causes exception.

Only middlewares with `:wrap` can short-circuit, `:enter`/`:leave` just modify
request/response.

The middlewares are applied in the order:

- Request flows from first to last.
- Response flows from last to first.
- Every middleware receives request from *previous* `:wrap`/`:enter`
  middlewares only.
- Every `:leave`/`:wrap` receives response from *next* middlewares.

The `xs` is validating for dependencies with [[validate-deps]]. The option
`:ignored-deps` contains dependency names to ignore in validation.
sourceraw docstring

validate-depsclj

(validate-deps xs)
(validate-deps xs ignored)

Throws exception if xs contains middleware with :deps and corresponding dependency is missing. The :deps is a map of required middleware names with value :before/:after:

[{:name `name1}
 {:name `name2 :deps {`name1 :before, `name3 :after}}
 {:name `name3}]
Throws exception if `xs` contains middleware with `:deps` and corresponding
dependency is missing. The `:deps` is a map of required middleware names with
value `:before`/`:after`:

    [{:name `name1}
     {:name `name2 :deps {`name1 :before, `name3 :after}}
     {:name `name3}]
sourceraw docstring

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

× close