This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-12
Channels
- # announcements (2)
- # architecture (1)
- # aws (22)
- # babashka (2)
- # beginners (39)
- # bristol-clojurians (2)
- # cider (1)
- # clj-kondo (12)
- # cljfx (75)
- # cljs-dev (16)
- # clojure (51)
- # clojure-berlin (1)
- # clojure-france (4)
- # clojure-nl (2)
- # clojure-norway (36)
- # clojurescript (5)
- # community-development (8)
- # data-science (1)
- # datomic (4)
- # emacs (4)
- # fulcro (7)
- # jobs-discuss (7)
- # juxt (1)
- # nrepl (3)
- # off-topic (38)
- # reitit (1)
- # ring (7)
- # sci (79)
- # shadow-cljs (5)
- # sql (15)
- # tools-deps (22)
- # uncomplicate (7)
- # vrac (1)
- # xtdb (18)
Hi, I have a doubt on the order of middleware application. Lets consider the following code (take from https://cljdoc.org/d/metosin/reitit/0.5.5/doc/ring/transforming-middleware-chain):
(require '[reitit.ring :as ring])
(require '[reitit.middleware :as middleware])
(defn wrap [handler id]
(fn [request]
(handler (update request ::acc (fnil conj []) id))))
(defn handler [{::keys [acc]}]
{:status 200, :body (conj acc :handler)})
(def app
(ring/ring-handler
(ring/router
["/api" {:middleware [[wrap 1] [wrap 2]]}
["/ping" {:get {:middleware [[wrap 3]]
:handler handler}}]])))
(app {:request-method :get, :uri "/api/ping"})
; {:status 200, :body [1 2 3 :handler]}
In this case, the order seems to be: first [wrap 1]
, then [wrap 2]
(based on the response body on the last line). But, in my code, the effect is reversed. Seems like I am missing something. Any help?