Fork me on GitHub
#yada
<
2018-11-13
>
genRaiy15:11:32

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

borkdude16:11:19

@raymcdermott we have something like this:

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

borkdude16:11:58

where log-charset is an interceptor function

genRaiy16:11:54

we have all our routes declared in a bidi form

genRaiy16:11:56

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

borkdude16:11:15

(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

genRaiy16:11:10

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

genRaiy16:11:50

but you are fancier than me 😉

borkdude16:11:06

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

borkdude16:11:25

that has things like auth etc configured

genRaiy16:11:58

ah, ok - we still have a sh1tload of boilerplate

genRaiy16:11:19

should clean it up once we get serious

borkdude16:11:21

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

genRaiy16:11:35

cool, makes sense

genRaiy16:11:43

thanks for the advice