This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-29
Channels
- # announcements (8)
- # aws (34)
- # beginners (92)
- # calva (19)
- # capetown (1)
- # cider (10)
- # cljs-dev (7)
- # cljsrn (11)
- # clojars (7)
- # clojure (130)
- # clojure-europe (4)
- # clojure-italy (4)
- # clojure-losangeles (1)
- # clojure-nl (11)
- # clojure-russia (1)
- # clojure-spec (4)
- # clojure-uk (64)
- # clojurescript (51)
- # cursive (9)
- # data-science (6)
- # datomic (29)
- # emacs (3)
- # figwheel-main (14)
- # fulcro (4)
- # graphql (3)
- # jackdaw (2)
- # jobs (4)
- # kaocha (17)
- # leiningen (3)
- # luminus (1)
- # off-topic (46)
- # pedestal (6)
- # portkey (2)
- # re-frame (6)
- # reagent (1)
- # reitit (9)
- # shadow-cljs (9)
- # sql (10)
- # yada (6)
When using the table routing syntax, what is the suggested way of applying a seq of interceptors to e.g. all routes under a given path?
I had thought that registering the interceptors as metadata in a wrapping vector would do it but that seems not to be true
Hi @donaldball! You can create a var bound to the vector of common interceptors and conj
your handler into it. With the table routing syntax, you’ll need to do this for each route
(def common-interceptors [(body-params/body-params) http/html-body])
;; Tabular routes
(def routes #{["/" :get (conj common-interceptors `home-page)]
["/about" :get (conj common-interceptors `about-page)]})
Yeah, that’s what I’m doing now, but it’s ergonomically less appealing than earlier syntaxes allowed. Then again, that’s what fns are for. 🙂