pedestal

dehli 2020-09-30T02:54:27.030900Z

hello, i have an overall question about interceptors. if you have an interceptor that depends on another interceptor is there a way that’s represented? i was thinking that the dependency could be enforced by checking if the expected value is there and if not, then inject the required interceptor. is there some better way? Basically what I’m doing now is:

(def my-interceptor
  {:enter (fn [{:keys [required-key] :as ctx}]
            (if (nil? required-key)
              (inject-then-reexecute ctx required-key-interceptor)
              (continue-with-execution ctx)))})
And inject-then-reexecute will move the current interceptor from the stack back to the queue and then add whatever the dependency interceptor is

dehli 2020-09-30T12:07:33.031700Z

Thanks! That makes sense. I like that better!

2020-10-01T11:16:20.037700Z

i wrote a little library many years ago to help deal with this https://github.com/oliyh/angel-interceptor

dehli 2020-10-01T23:02:44.059200Z

Awesome, thanks for sharing! Will check it out

2020-09-30T06:13:21.031200Z

Yes, you can at least do it with the linear router. Make sure to take the order into account (shorter route first)

2020-09-30T06:15:33.031400Z

I would consider the missing interceptor a bug, so if anything, I'd throw an exception stating exactly that ("missing xyz in context. Is interceptor-xyz setup?")