Liking cljdoc? Tell your friends :D

io.pedestal.interceptor.helpersdeprecated

A collection of interceptor helpers.

The usage of the Interceptor API is preferred over the macros defined in this namespace. Usage of the macro helpers should be limited to cases where you are porting an existing Pedestal code base.

The helper macros predate the interceptor API and can break AOT compilation but they are maintained for backwards compatibility. Refer to https://github.com/pedestal/pedestal/issues/308 and https://github.com/pedestal/pedestal/pull/301 for more details about macro helper issues and the rationale for the Interceptor API.

This namespace has been effectively deprecated since 2016, and is fully deprecated in release 0.6.0.

A collection of interceptor helpers.

The usage of the Interceptor API is preferred over the macros
defined in this namespace. Usage of the macro helpers should be
limited to cases where you are porting an existing Pedestal code
base.
 
The helper macros predate the interceptor API and can break AOT
compilation but they are maintained for backwards
compatibility. Refer to
https://github.com/pedestal/pedestal/issues/308 and
https://github.com/pedestal/pedestal/pull/301 for more details about
macro helper issues and the rationale for the Interceptor API.

This namespace has been effectively deprecated since 2016, and is fully
deprecated in release 0.6.0.
raw docstring

afterclj

(after f)
(after f & args)

Return an interceptor which calls f on context during the leave stage.

Return an interceptor which calls `f` on context during the leave
stage.
sourceraw docstring

aroundclj

(around f1 f2)
(around n f1 f2)

Return an interceptor which calls f1 on context during the enter stage, and calls f2 on context during the leave stage.

Return an interceptor which calls `f1` on context during the enter
stage, and calls `f2` on context during the leave stage.
sourceraw docstring

beforeclj

(before f)
(before f & args)

Returns an interceptor which calls f on context during the enter stage.

Returns an interceptor which calls `f` on context during the enter
stage.
sourceraw docstring

defaftercljmacro

(defafter macro-name__12339__auto__ & args__12340__auto__)

Defines an after interceptor. The defined function is processed during the leave stage of interceptor execution. The implicitly created function will operate on context, and return a value used as the new context, e.g.:

(defafter check-zotted [context] (if-not (:zotted context) (throw (ex-info "Context was not zotted!" {:context context})) context))

Defines an after interceptor. The defined function is processed
during the leave stage of interceptor execution. The implicitly
created function will operate on context, and return a value used as
the new context, e.g.:

(defafter check-zotted
  [context]
  (if-not (:zotted context)
    (throw (ex-info "Context was not zotted!"
                    {:context context}))
    context))
sourceraw docstring

defaroundcljmacro

(defaround n & args)

Defines an around interceptor. The definition resembles a multiple arity function definition, however both fns are 1-arity. The first fn will be called during the enter stage, the second during the leave stage, e.g.:

(defaround aroundinterceptor ([context] (assoc context :around :entering)) ([context] (assoc context :around :leaving)))

Defines an around interceptor. The definition resembles a multiple
arity function definition, however both fns are 1-arity. The first
fn will be called during the enter stage, the second during the
leave stage, e.g.:

(defaround aroundinterceptor
  ([context] (assoc context :around :entering))
  ([context] (assoc context :around :leaving)))
sourceraw docstring

defbeforecljmacro

(defbefore macro-name__12339__auto__ & args__12340__auto__)

Defines a before interceptor. The defined function performs processing during interceptor execution during the enter stage. The implicitly created function will operate on context, and return a value used as the new context, e.g.:

(defbefore flag-zotted [context] (assoc context :zotted true))

Defines a before interceptor. The
defined function performs processing during interceptor execution
during the enter stage. The implicitly created function will operate
on context, and return a value used as the new context, e.g.:

(defbefore flag-zotted
  [context]
  (assoc context :zotted true))
sourceraw docstring

defhandlercljmacro

(defhandler macro-name__12339__auto__ & args__12340__auto__)

Defines a handler interceptor. The definition mirrors a ring-style request handler and is made in terms of a ring style request. The implicitly created interceptor will extract the request from the context it receives, pass it to the defined function, and then associate the return value from the defined function as into context with the :response key and return context, e.g.:

(defhandler hello-name [request] (ring.util.response/response (str "Hello, " (-> request :params :name))))

This is equivalent to:

(defbefore hello-name [context] (let [request (:request context) response (ring.util.response/response (str "Hello, " (-> request :params :name)))] (assoc context :response response)))

Defines a handler interceptor. The definition mirrors a ring-style
request handler and is made in terms of a ring style request. The
implicitly created interceptor will extract the request from the
context it receives, pass it to the defined function, and then
associate the return value from the defined function as into
context with the :response key and return context, e.g.:

(defhandler hello-name
  [request]
  (ring.util.response/response
    (str "Hello, " (-> request
                         :params
                         :name))))

This is equivalent to:

(defbefore hello-name
  [context]
  (let [request (:request context)
        response (ring.util.response/response
                   (str "Hello, " (-> request
                                        :params
                                        :name)))]
    (assoc context :response response)))
sourceraw docstring

definterceptorcljmacrodeprecated

(definterceptor name & body)

Define an instance of an interceptor and store it in a var. An optional doc string can be provided. The body can be anything that satisfies the IntoInterceptor protocol.

usage: (definterceptor encode-response "An interceptor that encodes the response as json" (on-response encode-json))

Alternatively, you may also: (def encode-response "An interceptor that encodes the response as json" (on-response encode-json)

Define an instance of an interceptor and store it in a var. An
optional doc string can be provided.
The body can be anything that satisfies the IntoInterceptor protocol.

usage:
  (definterceptor encode-response
     "An interceptor that encodes the response as json"
     (on-response encode-json))

Alternatively, you may also:
  (def encode-response
    "An interceptor that encodes the response as json"
    (on-response encode-json)
sourceraw docstring

defmiddlewarecljmacro

(defmiddleware n & args)

Defines a middleware interceptor. The definition resembles a multiple arity function definition, however both fns are 1-arity. The first fn will be called during the enter stage with the value of the :request key in the context, the second during the leave stage with the response key in the context, e.g.:

(defmiddleware middleware-interceptor ([request] (assoc request :middleware :on-request)) ([response] (assoc response :middleware :on-response)))

Defines a middleware interceptor. The definition resembles a
multiple arity function definition, however both fns are
1-arity. The first fn will be called during the enter stage with the
value of the :request key in the context, the second during the
leave stage with the response key in the context, e.g.:

(defmiddleware middleware-interceptor
  ([request] (assoc request :middleware :on-request))
  ([response] (assoc response :middleware :on-response)))
sourceraw docstring

defon-requestcljmacro

(defon-request macro-name__12339__auto__ & args__12340__auto__)

Defines an on-request interceptor. The definition performs pre-processing on a request during the enter stage of interceptor execution. The implicitly created interceptor will extract the request from the context it receives, pass it to the defined function, and then associate the return value from the defined function as into context with the :request key and return context, e.g.:

(defon-request parse-body-as-wibblefish [request] (assoc request :wibblefish-params (wibblefish-parse (:body request))))

This is equivalent to:

(defbefore parse-body-as-wibblefish [context] (let [request (:request context) new-request (assoc request :wibblefish-params (wibblefish-parse (:body request)))] (assoc context :request new-request)))

Defines an on-request interceptor. The definition performs
pre-processing on a request during the enter stage of interceptor
execution. The implicitly created interceptor will extract the
request from the context it receives, pass it to the defined
function, and then associate the return value from the defined
function as into context with the :request key and return
context, e.g.:

(defon-request parse-body-as-wibblefish
  [request]
  (assoc request :wibblefish-params
         (wibblefish-parse (:body request))))

This is equivalent to:

(defbefore parse-body-as-wibblefish
  [context]
  (let [request (:request context)
        new-request (assoc request :wibblefish-params
                           (wibblefish-parse (:body request)))]
    (assoc context :request new-request)))
sourceraw docstring

defon-responsecljmacro

(defon-response macro-name__12339__auto__ & args__12340__auto__)

Defines an on-response interceptor. The definition performs post processing on a response during the leave stage of interceptor execution. The implicitly created interceptor will extract the response from the context it receives, pass it to the defined function, and then associate the return value from the defined function into context with the :response key and return context, e.g.:

(defon-response change-body-to-html [response] (assoc response :body (render-to-html (:body response))))

This is equivalent to:

(defafter change-body-to-html [context] (let [response (:response context) new-response (assoc response :body (render-to-html (:body response)))] (assoc context :response new-response)))

Defines an on-response interceptor. The definition performs post
processing on a response during the leave stage of interceptor
execution. The implicitly created interceptor will extract the
response from the context it receives, pass it to the defined
function, and then associate the return value from the defined function
into context with the :response key and return context, e.g.:

(defon-response change-body-to-html
  [response]
  (assoc response :body
         (render-to-html (:body response))))

This is equivalent to:

(defafter change-body-to-html
  [context]
  (let [response (:response context)
        new-response (assoc response :body
                            (render-to-html (:body response)))]
    (assoc context :response new-response)))
sourceraw docstring

handlerclj

(handler f)
(handler n f)

Returns an interceptor which calls f on the :request value of context, and assoc's the return value as :response into context during the enter stage.

Returns an interceptor which calls f on the :request value of
context, and assoc's the return value as :response into context during the
enter stage.
sourceraw docstring

infer-rest-interceptor-functionclj

(infer-rest-interceptor-function args)

Given list args, return the rest of args that would remain after removing the elements of args that specify the form returned by infer-first-interceptor-function.

Given list `args`, return the rest of args that would remain after
removing the elements of args that specify the form returned by
infer-first-interceptor-function.
sourceraw docstring

middlewareclj

(middleware f1 f2)
(middleware n f1 f2)

Returns an interceptor which calls f1 on the :request value of context during the enter stage, and f2 on the :response value of context during the leave stage.

Returns an interceptor which calls `f1` on the :request value of
context during the enter stage, and `f2` on the :response value of
context during the leave stage.
sourceraw docstring

on-requestclj

(on-request f)
(on-request f & args)

Returns an interceptor which updates the :request value of context with f during the enter stage.

Returns an interceptor which updates the :request value of context
with f during the enter stage.
sourceraw docstring

on-responseclj

(on-response f)
(on-response f & args)

Returns an interceptor which updates the :response value of context with f during the leave stage.

Returns an interceptor which updates the :response value of context
with f during the leave stage.
sourceraw docstring

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

× close