Fork me on GitHub
#duct
<
2018-05-28
>
smonk14:05:56

something like that works: :autocmd BufWritePost *.clj execute ":Eval (do (user/dev) (reset))"

scaturr14:05:01

Can anyone steer me towards adding an api middleware? I’ve defined the following in my project:

(ns slack-api.middleware.apigw
  (:require [ring.middleware.apigw :as apigw]
            [integrant.core :as ig]))

(defmethod ig/init-key :slack-api.middleware/apigw [_ options]
  #(apigw/wrap-apigw-lambda-proxy % (or options {})))
And I’m trying to include it like so in config.edn:
:duct.module.web/api
 {:middleware [#ig/ref :slack-api.middleware/apigw]}

scaturr14:05:24

But I get the following error at the repl:

dev> (reset)
:reloading (slack-api.main)
clojure.lang.ExceptionInfo: Missing definitions for refs: :slack-api.middleware/apigw

scaturr14:05:42

I’m sure I’m missing something fundamental 😞 - but I’m having a hard time seeing what

myguidingstar14:05:52

@scaturr did you "call" the key with its arguments in config.edn?

myguidingstar14:05:07

something like :slack-api.middleware/apigw {}

scaturr14:05:48

ah! I did not - that did the trick. Thank you!

weavejester15:05:32

Also, I believe that the :duct.core/handler key should be used to set the middleware, @scaturr

scaturr15:05:42

Is that just a matter of convention? Or it will not work the other way? I thought I saw in the web module that the config to ::api gets merged?

scaturr15:05:28

(haven’t actually deployed to api gateway via lambda yet so haven’t tested whether it works - or if I even can deploy to lambda)

weavejester15:05:11

I’m pretty sure it won’t work, @scaturr. The web module doesn’t pull in the :middleware key from the options.

scaturr15:05:27

👌 thank you!

scaturr15:05:37

duct looks awesome - thank you for working on it

weavejester15:05:58

I just need to find some time to finish the next version of it 🙂

😁 4
👍 4