Fork me on GitHub
#duct
<
2020-04-20
>
rickmoynihan09:04:10

@sixofhearts You can always extend the multi-method handler/sync-default to support your own custom keyword responses. Or possibly mix the response headers in, in a middleware afterwards — depending of course on exactly what you need to do.

paulschun09:04:03

Ah, thanks @rickmoynihan I think my case calls for extending handler/sync-default - good call

kelveden11:04:41

This may well be more of an ataraxy question than duct as such but I'll ask anyway... Is there any way of explicitly specifying the order in which middleware for a specific route is applied? So for example, if I have this very contrived config:

{:duct.router/ataraxy
 {:routes     {"/my/route"
               {:get ^{:aaa-middleware {:args :whatever-aaa}
                       :bbb-middleware {:args :whatever-bbb}}
                     [:my/handler]}}
  :middleware {:aaa-middleware #ig/ref :middleware/aaa
               :bbb-middleware #ig/ref :middleware/bbb}}}
i.e. have a single route /my/route that has two pieces of middleware assigned to it: :aaa-middleware and :bbb-middleware. When running code I see that :bbb-middleware gets applied before :aaa-middleware . (In fact, the middleware seems to be being applied in reverse-alphabetical order: if I change the name of aaa-middleware to zzz-middleware then it does get applied first.) So, my question is: can I somehow explicitly say that I want :aaa-middleware applied first?

kelveden11:04:00

(I tried re-ordering the middleware map itself and that didn't make any difference - quite reasonably as maps aren't explicitly ordered.)

kelveden12:04:57

I think that this line is what's doing the "alphabetical" ordering: https://github.com/weavejester/ataraxy/blob/master/src/ataraxy/core.clj#L297. But I can't think of a logical reason why such sorting would be required.

kwrooijen12:04:30

AFAIK there's no way to change the order. I think there's an ataraxy issue about this

kwrooijen12:04:46

Alternatively you could create an init-key that comps the middleware that you need

👍 4
kelveden12:04:21

Yeah I agree comping the middleware is probably the best workaround. Thanks.