Fork me on GitHub
#pedestal
<
2020-03-03
>
isak16:03:40

Are these docs still correct about early termination happening if an interceptor in the chain returns a response map? http://pedestal.io/reference/servlet-interceptor#_early_termination For me it doesn't work - it still executes later interceptors

isak16:03:58

Here is my interceptor that I expected would lead to early termination (but doesn't) based on that documentation:

(def test-interceptor
  {:name ::test-interceptor
   :enter
   (fn [ctx]
     (log/info :msg "Enter test-interceptor")
     (assoc ctx :response {:status 200 :body "test"}))
   :leave (fn [ctx]
            (log/info :msg "leave test-interceptor")
            ctx)})

isak16:03:35

Ah, it didn't work because it also needed :headers :

(defn response?
  "True if the supplied value is a valid response map."
  {:added "1.1"}
  [resp]
  (and (map? resp)
       (integer? (:status resp))
       (map? (:headers resp))))