reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
CambodianCoder 2020-03-19T18:19:37.097300Z

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.md

CambodianCoder 2020-03-20T15:43:39.100600Z

Thanks

CambodianCoder 2020-03-24T22:44:01.129500Z

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

2020-03-19T19:48:16.097700Z

(-> request :reitit.core/match :path-params :id)

johan 2020-03-19T23:22:18.099Z

Does anyone know how to had swagger model ? like in the official swagger examples https://petstore.swagger.io/#/pet/addPet