This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-08
Channels
- # architecture (8)
- # aws (25)
- # babashka (9)
- # beginners (57)
- # calva (16)
- # cider (16)
- # clj-kondo (3)
- # cljdoc (13)
- # cljsrn (6)
- # clojure (272)
- # clojure-europe (36)
- # clojure-losangeles (1)
- # clojure-nl (8)
- # clojure-poland (3)
- # clojure-spec (4)
- # clojure-uk (8)
- # clojuredesign-podcast (9)
- # clojurescript (92)
- # code-reviews (1)
- # conjure (8)
- # core-async (1)
- # cursive (13)
- # datalog (1)
- # datascript (35)
- # datomic (76)
- # duct (10)
- # emacs (5)
- # events (7)
- # figwheel-main (1)
- # fulcro (35)
- # graalvm (20)
- # graphql (6)
- # jobs (3)
- # klipse (1)
- # london-clojurians (1)
- # malli (3)
- # off-topic (223)
- # pathom (2)
- # pedestal (13)
- # portal (1)
- # reitit (6)
- # remote-jobs (1)
- # shadow-cljs (21)
- # specter (2)
- # sql (63)
- # tools-deps (85)
- # tree-sitter (4)
- # xtdb (6)
(defn respond-hello [db request]
{:status 200 :body (str (request->str (jdbc/execute! db ["SELECT * FROM PERSON"]))
"\n"
(request->str request))})
(defn routes [db]
(route/expand-routes
#{["/greet" :get (partial respond-hello db) :route-name ::respond-hello]
["/" :get respond-elm-app :route-name ::spa]}))
(defn start-server
[config db]
(let [attach-system {:enter (fn [context]
(assoc context :context {:db db
:config config}))}]
(-> {:env :dev
::http/routes (routes db)
::http/port (config/server-port config)
::http/type :jetty
::http/join? false}
(http/default-interceptors)
(update :io.pedestal.http/interceptors conj attach-system)
http/create-server
http/start)))
[{:type java.lang.AssertionError
:message "Assert failed: (every? interceptor/interceptor? interceptors)"
:at [io.pedestal.interceptor.chain$enqueue invokeStatic "chain.clj" 273]}]
but the error is the same regardless if I have a :name
on the interceptor so i feel at a loss
What you inject there isn't an interceptor yet. You should call io.pedestal.interceptor/interceptor on that map before you inject it.
Hello all. I'm making my first attempt to build an API, and I can't figure out how to get POSTed application/json data. My context in my route handler doesn't seem to have the request body json in it.
Are you using the io.pedestal.http.body-params/body-params interceptor? If so, you should look under [:request :io.pedestal.http.body-params/body-params]
Thanks. I did finally get past the problem. This seems to give me what I need: `
["/add-event" :post [(io.pedestal.http.body-params/body-params) pusher-api.incoming-data/add-event] :route-name :add-event]
my mistake was not calling body-params ( ). I was just referencing it 😛