yada 2018-11-13

dumb question … where do I put the config for insert-interceptor … in routes?

@raymcdermott we have something like this:

(-> model
        ...
        yada/resource
        (insert-interceptor i/available?
                            log-charset)
...)

where log-charset is an interceptor function

we have all our routes declared in a bidi form

ok, I guess I don’t know what your flow does there

(defn insert-interceptor [res point & interceptors]
  (update res :interceptor-chain
          (partial mapcat (fn [i]
                            (if (= i point)
                              (concat interceptors [i])
                              [i])))))
insert-interceptor takes a resource, this is decoupled from your bidi-routes

I was thinking that I would just add another function to wrap the insertion

but you are fancier than me 😉

we have a standard resource model that we use to create yada resources

that has things like auth etc configured

ah, ok - we still have a sh1tload of boilerplate

should clean it up once we get serious

so we enrich that with an interceptor for every resource we creeate

cool, makes sense

thanks for the advice