This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-19
Channels
- # announcements (6)
- # aws (10)
- # beginners (73)
- # bristol-clojurians (2)
- # calva (9)
- # cider (25)
- # clj-kondo (7)
- # clojure (160)
- # clojure-dev (2)
- # clojure-europe (63)
- # clojure-italy (7)
- # clojure-nl (10)
- # clojure-uk (76)
- # clojuredesign-podcast (6)
- # clojurescript (63)
- # cursive (6)
- # data-science (3)
- # datomic (26)
- # duct (59)
- # emacs (1)
- # fulcro (12)
- # graalvm (17)
- # hoplon (23)
- # jobs-discuss (2)
- # kaocha (6)
- # meander (7)
- # off-topic (3)
- # pathom (2)
- # rdf (68)
- # re-frame (12)
- # reagent (20)
- # reitit (5)
- # ring (3)
- # ring-swagger (1)
- # shadow-cljs (14)
- # spacemacs (10)
- # sql (3)
- # tools-deps (30)
- # yada (9)
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#60840400Does anyone know how to had swagger model ? like in the official swagger examples https://petstore.swagger.io/#/pet/addPet