Fork me on GitHub
#yada
<
2018-11-06
>
stijn19:11:14

hi, let's say I have an API that has produces both application/json and application/edn. In case of an application/json response, i would like to update the response to strip namespaces from keywords. how would I implement this in a clean way in yada? I can walk the bidi tree and look at each methods :response function, and adapt that based on the negotiated content-type, but isn't there a less 'invasive' way?

malcolmsparks19:11:05

I'm not clear what you're asking

stijn19:11:20

oh, and I only want it to happen for /api/v2 e.g. and not for /api/v1 (so no yada-wide setting by overriding e.g. render-map and render-seq)

malcolmsparks19:11:44

You can ask in a response function what the negotiation is

stijn19:11:26

ok, I think that I will use that indeed

malcolmsparks19:11:48

Are you trying to do the same logic for many web resources?

stijn19:11:14

so walking the bidi routes and then wrapping the :response function should work

malcolmsparks19:11:29

You could add an interceptor after the response function interceptor

stijn19:11:41

ok, that's another idea

stijn19:11:54

yes, that'll probably be better 🙂

malcolmsparks19:11:59

But yes, decorating the response function is a fine approach too