This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-13
Channels
- # beginners (50)
- # boot (27)
- # bristol-clojurians (7)
- # cider (30)
- # clara (1)
- # cljs-dev (130)
- # cljsrn (14)
- # clojure (179)
- # clojure-austin (6)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-spec (19)
- # clojure-uk (54)
- # clojurescript (64)
- # core-async (3)
- # data-science (1)
- # datomic (66)
- # duct (11)
- # emacs (5)
- # figwheel (1)
- # fulcro (26)
- # funcool (7)
- # jobs (1)
- # jvm (6)
- # keechma (5)
- # lein-figwheel (5)
- # luminus (5)
- # lumo (1)
- # off-topic (93)
- # parinfer (37)
- # pedestal (15)
- # protorepl (10)
- # re-frame (42)
- # reagent (12)
- # shadow-cljs (71)
- # spacemacs (3)
- # specter (7)
- # vim (8)
- # yada (9)
I'm trying to do something pretty tricky with pedestal routers and interceptors. Essentially, part of my application is routed based on stateful data that can change at any time.
So I have a traditional (static) router, then an interceptor that builds (as needed) another router and adds it via io.pedestal.interceptor.chain/enqueue
What I see is execution of the router, then execution of my interceptor, then execution of interceptors in a route matched by the router.
And that's where I'd expect the router to match paths and choose a route, and add that route's interceptors/handler to the execution chain.
And those interceptors will put a :response into the context, which should trigger an unwind through the :leave events of all the interceptors so far.
But then on line 9, we see app-router enter stage, which to mind mind shouldn't take place.
Then on line 11 we start to see the interceptors chosen by the router start to execute.
So I think what happens is that the router and the app-dispatcher are enqueued initially. The router executes, matches a route, and adds its interceptors to the execution chain after the other app-dispatcher interceptor. app-dispatcher executes it's :enter stage, but does nothing THEN the route interceptors hits their :enter stage.
So I think I can get what I want by moving some logic in app-dispatcher to a :leave step instead, and only if there's no :request already.