@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.
Ah, thanks @rickmoynihan I think my case calls for extending handler/sync-default
- good call
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?(I tried re-ordering the middleware map itself and that didn't make any difference - quite reasonably as maps aren't explicitly ordered.)
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.
AFAIK there's no way to change the order. I think there's an ataraxy issue about this
Alternatively you could create an init-key that comps the middleware that you need
Yeah I agree comping the middleware is probably the best workaround. Thanks.
You're right that it was discussed a while back: https://github.com/weavejester/ataraxy/issues/11#issuecomment-350712543