Fork me on GitHub
#duct
<
2022-05-17
>
dmegas20:05:10

Hello all! I’m trying to leverage ^:replace to disable some of the default middleware included with duct.module.web/api , but can’t seem to make it work. A simplified version of my config.edn is as follows:

{:duct.profile/base
 {:duct.handler/root
  {:middleware ^{:replace true} [#ig/ref :duct.middleware.web/not-found
                                 #ig/ref :duct.middleware.web/format
                                 #ig/ref :duct.middleware.web/defaults]}

  :duct.router/ataraxy
  {:routes
   {[:get "/status"] [:my.handlers/status]}}}

 :duct.profile/dev   #duct/include "dev"
 :duct.profile/local #duct/include "local"
 :duct.profile/prod  {}

 :duct.module/logging {}

 :duct.module.web/api {}}
and the general idea is to disable the :duct.middleware.web/log-requests middleware that the web module brings in. I’m using [duct/core "0.7.0"] and [duct/module.web "0.7.0"]. In the repl when I try
(duct.core.merge/meta-merge  ^{:replace true} [{:key :duct.middleware.web/not-found}
                                                 {:key :duct.middleware.web/format}
                                                 {:key :duct.middleware.web/defaults}]

                               [{:key :duct.middleware.web/log-requests}
                                {:key :duct.middleware.web/log-errors}])
I get
[{:key :duct.middleware.web/not-found}
 {:key :duct.middleware.web/format}
 {:key :duct.middleware.web/defaults}]
if that makes any sense. Could it be that the :replace metadata gets lost somehow?