This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-17
Channels
- # bangalore-clj (1)
- # beginners (70)
- # boot (1)
- # cider (39)
- # cljs-dev (69)
- # clojure (56)
- # clojure-dev (1)
- # clojure-norway (1)
- # clojure-russia (4)
- # clojure-spec (1)
- # clojure-uk (10)
- # clojurescript (34)
- # clr (3)
- # community-development (3)
- # component (1)
- # datascript (1)
- # datomic (7)
- # emacs (1)
- # figwheel (3)
- # fulcro (5)
- # graphql (2)
- # hoplon (75)
- # jobs (4)
- # jobs-discuss (1)
- # luminus (15)
- # planck (3)
- # portkey (55)
- # re-frame (2)
- # reagent (2)
- # reitit (3)
- # ring (13)
- # ring-swagger (1)
- # shadow-cljs (72)
- # spacemacs (4)
- # tools-deps (2)
- # unrepl (7)
- # vim (2)
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]
@U06BE1L6T 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 @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.
@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”: 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.
@U0BKWMG5B Thanks for the tip!