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
For example...
(def find-by-id [:map
{:closed true}
[:id uuid?]])
["/:id" {:get {:handler (find-by-id app-config)
:parameters {:path specs/find-by-id}
will coerce that id to a uuid for me
yeah I know that I can go with the coercion stuff but I like the compact syntax of my stuff 🙂
😄
always room for one more framework 🙂
ok, just tested. I do in fact get :product-id:int "123"
. that is easy enough to convert. I'll just go with that 🙂
:thumbsup: