Fork me on GitHub
#ring
<
2018-03-17
>
Shantanu Kumar19:03:38

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

jumar13:03:58

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]}}

jumar13:03:15

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: https://github.com/weavejester/ataraxy/blob/master/src/ataraxy/core.clj#L199 Perhaps @U0BKWMG5B can give us a better solution for ANY.

weavejester13:03:35

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

weavejester13:03:22

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

weavejester13:03:10

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

weavejester13:03:35

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?

weavejester18:03:21

@U066J7E2U It’s documented in the README under “Handlers”: https://github.com/weavejester/ataraxy#handlers

weavejester18:03:16

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.