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]
@jumar Thanks. I’m doing this in a sub-map {:get [:foo] :put [:bar] :any [:baz]}
so can’t use that style
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: https://github.com/weavejester/ataraxy/blob/master/src/ataraxy/core.clj#L199
Perhaps @weavejester 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.
@weavejester Could you point me to some doc that shows how to customize the response for :ataraxy.error/unmatched-method
?
@kumarshantanu It’s documented in the README under “Handlers”: https://github.com/weavejester/ataraxy#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.
@weavejester Thanks for the tip!