How do you get a path-param out of a reitit backend route? I am trying to get the val associated with :id
in the following manner, but keep getting a 404 file not found error.
["/edit-job/:id" {:get (fn [{:keys [path-params ]}]
(crud-jobs/request-single-job (:id path-params)))}]
My front end routing has
["edit-job/:id"
{:name ::edit-job
:view #'confirm-job-modification-modal/edit-job
:controllers [{:params (fn [match]
(do (println match)
(:path-params (first (:controllers match)))))
:start (fn [item-id] (js/console.log "item start" item-id))
:stop (fn [item-id] (js/console.log "item stop" item-id))}]}]
, which works just fine (eg, the id shows in the URL and the right information about the job shows as well because it is already loaded into app-db
.) When I refresh the page, I want the data to still show up for that job, but I get a 404 error instead. What's the correct way to extract a path-param from a backend route? I have tried using the documentation at https://luminusweb.com/docs/routes.html and https://github.com/metosin/reitit/blob/master/README.mdThanks
For those who come across this later, I was able to extract the path-param from a backend-route as follows:
["/edit-job/:id"
{:get (fn [{:keys [path-params] :as _req}]
(http-response/ok (core/READ :jobs (Integer/valueOf (:id path-params)))))}]
Documentation on controllers and a working example came from https://clojureverse.org/t/how-do-you-accomplish-spa-re-frame-teardown/5516/6 and https://stackoverflow.com/questions/60763151/how-to-extract-a-path-param-from-a-reitit-backend-end-route/60840400#60840400(-> request :reitit.core/match :path-params :id)
Does anyone know how to had swagger model ? like in the official swagger examples https://petstore.swagger.io/#/pet/addPet