This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-25
Channels
- # beginners (20)
- # boot (25)
- # cider (1)
- # cljs-dev (7)
- # cljsjs (1)
- # cljsrn (1)
- # clojure (79)
- # clojure-austin (2)
- # clojure-berlin (13)
- # clojure-dusseldorf (1)
- # clojure-germany (7)
- # clojure-russia (10)
- # clojure-serbia (1)
- # clojure-spec (18)
- # clojure-uk (4)
- # clojured (1)
- # clojurescript (90)
- # cursive (10)
- # datomic (7)
- # emacs (14)
- # hoplon (6)
- # luminus (16)
- # lumo (4)
- # numerical-computing (2)
- # om (25)
- # om-next (1)
- # onyx (11)
- # pedestal (10)
- # protorepl (1)
- # reagent (11)
- # remote-jobs (1)
- # ring (1)
- # rum (38)
- # spacemacs (5)
- # test-check (7)
- # untangled (122)
- # vim (1)
- # yada (8)
Hi all, I am using pedestal based on Stuart Sierra component. Basically it is only 2 components now: Pedestal and Datomic. I am trying to inject datomic connection to intercepctors chain. But I keep getting this error: "You're trying to use something as an interceptor that isn't supported by the protocol; Perhaps you need to extend it?"
(defrecord Pedestal [service-map service db]
component/Lifecycle
(start [component]
(print (str "DB:" db))
(if service
component
(-> service-map
(assoc :http/routes (routes/routes db))
http/create-server
http/start
(assoc component :service))))
(stop [component]
(when service (http/stop service))
(assoc component :service nil)))
(defn routes [db-component]
(let [session-inter (session {:store (cookie/cookie-store)})
conn (:conn db-component)
attach-conn (attach-to-request :conn conn)]
(route/expand-routes
#{
["/" :get [attach-conn session-inter authenticate guard 'root]]
["/sign-up" :get [attach-conn session-inter 'show-sign-up]]
["/sign-up" :post [attach-conn session-inter (body-params) keyword-params 'sign-up]]
["/sign-in" :get [attach-conn session-inter 'show-sign-in]]
["/sign-in" :post [attach-conn session-inter (body-params) keyword-params 'sign-in]]
})))
(defn attach-to-request [name obj]
(interceptor
{:name ::attach-to-req
:enter (fn [ctx]
(assoc-in ctx [:request name] obj))}))
Please advice what I am doing wrong.
Thanks!@kirill.salykin i suspect this line (assoc component :service)
basically it will be expanded to (assoc (http/start ...) component service)
while what you want is (assoc component :service (http/start ...))
@mavbozo thanks!
looks like this is the reason
I find it helpful for me to split the Pedestal component into 2 components: Pedestal Service component just for preparing the service map for Pedestal Server component which is responsible for creating/starting/stopping the server
sounds interesting
I also found pedestal component from Sierra
trying this now
thanks for help!