Fork me on GitHub
#duct
<
2019-07-25
>
teaforthecat14:07:34

It looks like web handlers don’t get access to the instantiated top level keys, such as a db connection. For example in:

(defmethod ig/init-key :foobar.handler/example [_ {:keys [db] :as options}]
  (context "/example" []
    (GET "/" []
      {:body {:example "data"}})))
db will be a function and not the instantiated object I’m looking for. I must be missing something, I’m not seeing how to provide the db connection to the web handler.

teaforthecat14:07:32

(and if I call that function, I get the instantiated object)

jahson18:07:48

What is your config.edn?

teaforthecat19:07:13

oops, it looks like I must have been following some module code for inspiration when writing the db part - modules return functions that accept the conf, but regular components do not. sorry for the noise!

👍 4
jahson21:07:20

Basically, what you get is what you returned from ig/init-key multimethod.