This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-05
Channels
- # aleph (90)
- # announcements (4)
- # aws (2)
- # beginners (61)
- # calva (2)
- # cljs-dev (8)
- # cljsrn (12)
- # clojars (4)
- # clojure (42)
- # clojure-europe (1)
- # clojure-finland (1)
- # clojure-greece (2)
- # clojure-houston (1)
- # clojure-italy (3)
- # clojure-nl (30)
- # clojure-spec (41)
- # clojure-uk (87)
- # clojurescript (44)
- # cursive (12)
- # data-science (11)
- # datomic (24)
- # defnpodcast (1)
- # fulcro (18)
- # hyperfiddle (1)
- # jobs (2)
- # juxt (11)
- # kaocha (3)
- # london-clojurians (5)
- # mount (2)
- # nrepl (2)
- # off-topic (9)
- # onyx (25)
- # other-languages (1)
- # parinfer (3)
- # pathom (5)
- # pedestal (3)
- # portkey (1)
- # re-frame (21)
- # reagent (24)
- # remote-jobs (7)
- # schema (2)
- # shadow-cljs (59)
- # spacemacs (5)
- # specter (7)
- # sql (9)
- # tools-deps (13)
Hi there. New to pedestal. Happy to be corrected.
I was extending the example in the official pedestal guide (specifically the rest api example: http://pedestal.io/guides/your-first-api)
Wanted to implement a :delete
interceptor (just in order to understand). tried the following:
(def list-delete
{:name :list-delete
:enter
(fn [context]
(let [nm (get-in context [:request :query-params :name])
db-id (filter (comp #{nm} (:tx-data context)) (keys (:tx-data context)))]
(update context :tx-data dissoc db-id)))})
the original interceptor that creates the list is:
(def list-create
{:name :list-create
:enter
(fn [context]
(let [nm (get-in context [:request :query-params :name] "Unnamed List")
new-list (make-list nm)
db-id (str (gensym "l"))]
(assoc context :tx-data [assoc db-id new-list])))})
the original route for the :post
is: ["/todo" :post [db-interceptor list-create]]
so my :delete root is: ["/todo" :delete [db-interceptor list-delete]]
But trying the test: (test-request :delete "/todo?name=some-list")
when the state is:
{"l30491" {:name "my-other-list", :items {}}, "l30517" {:name "yes-list", :items {}}, "l30520" {:name "no-list", :items {}}, "l30527" {:name "no-list", :items {}}, "l30618" {:name "some-list", :items {}}}
does not delete the list in question....
Note that some-list
is the :name value in a map which is a value of the string "l30618" ... I think that my list-delete
function should do the job, but I suspect that I don't understand something basic either about interceptors or about how :delete should be called in a REST api....@adamgefen At a glance, it doesn’t look like your list-delete
impl is correct