This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-11
Channels
- # announcements (6)
- # babashka (61)
- # beginners (85)
- # calva (21)
- # cider (6)
- # clara (9)
- # clj-http (1)
- # clj-kondo (35)
- # cljfx (6)
- # clojure (91)
- # clojure-australia (11)
- # clojure-europe (23)
- # clojure-italy (7)
- # clojure-losangeles (2)
- # clojure-nl (27)
- # clojure-uk (107)
- # clojurescript (4)
- # community-development (1)
- # cursive (69)
- # emacs (12)
- # fulcro (29)
- # graalvm (25)
- # honeysql (10)
- # hugsql (3)
- # integrant (13)
- # jobs (4)
- # kaocha (3)
- # keechma (1)
- # lambdaisland (3)
- # leiningen (2)
- # meander (17)
- # mount (3)
- # observability (1)
- # off-topic (86)
- # pathom (3)
- # polylith (2)
- # practicalli (14)
- # reitit (14)
- # shadow-cljs (61)
- # startup-in-a-month (1)
- # tools-deps (9)
- # vim (54)
- # xtdb (16)
would something like this be a valid reitit route?
["/id/:entry-id"
{:get {:handler entry-id
:parameters {:path {:entry-id int?}}}}
{:put {:handler replace-entry-at-id
:parameters {:path {:entry-id int?
:body string?}}}}]
the get request works, but the put 404s
the put and get call.
(defn fetch-by-id
[id]
(ajax/GET "/entries/id/:entry-id" {:handler #(swap! state entry-handler %1)
:params {:entry-id id}}))
(defn send-update-by-id
[id]
(ajax/PUT "/entries/id/:entry-id" {:handler #(println %)
:params {:entry-id id
:body (create-raw)}}))
ahh I realized :get and :put have to be in the same map, just have a 400 error now
hey everyone. I'd planning to switch some of my routing from my ancient library I wrote myself to reitit. I'm only missing one thing that I kinda got used to and like and wonder if this is something I can easily get done with reitit or if that will get tricky? basically my route syntax matches what reitit already allows "/product/{product-id}"
except that it takes an optional "type" conversion via "/product/{product-id:int}"
actually as I write that I'll probably get :product-id:int "123"
in the match data which I could trivially convert later on
For my applications, I'm relying upon malli to do the coercion for me, seems to work out quite well
["/:id" {:get {:handler (find-by-id app-config)
:parameters {:path specs/find-by-id}
yeah I know that I can go with the coercion stuff but I like the compact syntax of my stuff 🙂