Fork me on GitHub
Shantanu Kumar19:03:38

Hi, does anybody here know how to express Compojure’s ANY method match in Ataraxy?


I guess you just leave out a method in your route definition. Like "/example" [:root/example] instead of [:get "/example"] [:root/example]

Shantanu Kumar13:03:14

@U06BE1L6T Thanks. I’m doing this in a sub-map {:get [:foo] :put [:bar] :any [:baz]} so can’t use that style

Shantanu Kumar13:03:26

Like {"/the/uri" {:get [:foo] :put [:bar] :any [:baz]}}


I tried a hack with using nil instead of method keyword but that's not a valid route. I can't think of any other option than to explicitly state other methods. I looked here: Perhaps @U0BKWMG5B can give us a better solution for ANY.


You can do it a few different ways, depending on what you intend to do.


{"/the/uri" {:get [:foo] :put [:bar] "" [:baz]}} will work


But often a method “catch-all” route is used to return a “method not found” status


And for that purpose the :ataraxy.error/unmatched-method result is a better solution.

Shantanu Kumar17:03:07

@U0BKWMG5B Could you point me to some doc that shows how to customize the response for :ataraxy.error/unmatched-method?


@U066J7E2U It’s documented in the README under “Handlers”:


The way you attach handlers to results in Ataraxy works for both the results you set up, and the error results Ataraxy uses when an error happens.