yada

Geoffrey Gaillard 2019-02-20T21:44:27.008700Z

I'm discovering and assessing yada for a future api project. So far so good. But I don't know how I am supposed to implement a generic middleware/interceptor that can be applied to multiple resources. Some resources should be secured and accessed by administrator only. If I wrap them with a ring middleware they don't appear in swagger anymore. I could make an interceptor but yada documentation is light on this topic. Should I put it in :interceptor-chain? Should I derive yada.yada/default-interceptor-chain, add my interceptor at the correct place?

dominicm 2019-02-20T21:49:27.009500Z

@ggaillard the general recommendation on this is to treat your yada resources on data and walk over your bidi structure in order to locate admin routes.

dominicm 2019-02-20T21:50:03.010400Z

e.g.

[
["/admin" (clojure.walk/walk add-admin-auth [...])]
["/something-else" ...]
]

Geoffrey Gaillard 2019-02-20T21:57:14.010500Z

Thanks! If I get it right add-admin-auth is supposed to alter the resource map to change the interceptor chain and/or wrap the :authorize function?

dominicm 2019-02-20T22:00:02.010700Z

What would you do on an individual yada resource to make it an admin one? I suspect you would set your authorize function yeah

Geoffrey Gaillard 2019-02-20T22:12:29.010900Z

Ok make sense. Thank you 🙂