This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-24
Channels
- # arachne (1)
- # aws (1)
- # beginners (43)
- # boot (67)
- # cider (7)
- # cljs-dev (14)
- # cljsjs (6)
- # clojure (215)
- # clojure-czech (2)
- # clojure-dev (12)
- # clojure-dusseldorf (2)
- # clojure-italy (1)
- # clojure-russia (22)
- # clojure-spec (2)
- # clojure-uk (33)
- # clojurescript (85)
- # cryogen (2)
- # cursive (1)
- # datascript (22)
- # datomic (18)
- # dirac (8)
- # hoplon (9)
- # klipse (1)
- # lein-figwheel (5)
- # leiningen (126)
- # off-topic (1)
- # om (57)
- # onyx (159)
- # pedestal (33)
- # planck (2)
- # re-frame (52)
- # reagent (3)
- # ring (2)
- # ring-swagger (16)
- # test-check (12)
- # testing (5)
- # untangled (86)
- # vim (6)
Hi folks, does anyone have an example of a trivial or small Pedestal app using component?
Excuse me while I wipe the egg off my face…
Much appreciated
Caused by: java.lang.IllegalArgumentException: No matching ctor found for class io.pedestal.interceptor.helpers$before$fn__23165
it's making me wonder if I've deviated from some normal way the pedestal namespaces are imported
Hmm... it doesn't look like a require
problem. It looks like what happens when a macro emits a function value.
(defroutes
routes
[[["/__health" {:get health}]
["/api"
^:interceptors [auth/configure-authentication auth/check-authentication]
["/test" {:get echo}]
["/keyword-demo" {:get keyword-demo-route}]]]])
(defbefore
check-authentication
[{:keys [request auth-backends] :as context}]
(let [req (apply authentication-request request auth-backends)]
(if (:identity req)
(assoc context :request req)
(-> context
terminate
(assoc :response {:status 401
:body {:message "Unauthorized"}
:headers {"WWW-Authenticate" (format "Basic realm=\"%s\"" "Blip")}})))))
Yep if I commented out those defbefores it started working. What's weird is that they were working in regular REPL, when I switched to debug REPL that's when they started barfing
My advice would be to rework it from using defbefore. Hang on one minute and I'll show you an example.
(def check-authentication
{::check-authentication
:enter
(fn [{:keys [request auth-backends] :as context}]
(let [req (apply authentication-request request auth-backends)]
(if (:identity req)
(assoc context :request req)
(-> context
terminate
(assoc :response {:status 401
:body {:message "Unauthorized"}
:headers {"WWW-Authenticate" (format "Basic realm=\"%s\"" "Blip")}}
)))))})