This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-13
Channels
- # announcements (6)
- # babashka (96)
- # beginners (159)
- # calva (16)
- # cider (17)
- # clj-kondo (4)
- # cljdoc (6)
- # cljfx (3)
- # clojure (202)
- # clojure-europe (21)
- # clojure-italy (2)
- # clojure-nl (36)
- # clojure-spec (6)
- # clojure-uk (16)
- # clojurescript (29)
- # conjure (25)
- # cursive (29)
- # data-science (12)
- # datalog (18)
- # datomic (58)
- # depstar (73)
- # duct (16)
- # emacs (65)
- # events (3)
- # fulcro (8)
- # honeysql (12)
- # jackdaw (6)
- # jobs (7)
- # jobs-discuss (3)
- # kaocha (50)
- # leiningen (8)
- # lsp (14)
- # malli (83)
- # meander (34)
- # off-topic (2)
- # polylith (4)
- # proletarian (7)
- # re-frame (8)
- # releases (9)
- # remote-jobs (3)
- # shadow-cljs (101)
- # sql (1)
- # tools-deps (48)
- # vim (7)
- # xtdb (13)
- # yada (14)
Hi folks, I am still using an old version of duct and I have a question. Say one of my components is referencing a composite key that is defined in one of the :include
but I want to override with a new implementation of init-key
How I would go about that?
One thing that I cannot do is to modify the original files, so it will have to go in a separate .edn
file...
I was thinking of doing something like
(merge (io/resource "config.edn")
(io/resource "overrides.edn"))
forgot to mention that this is not as dev
profile but it will be read by a completely separate "production" app
We pass multiple profiles
to (duct/prep-config (read-config) profiles)
, so that later profiles overwrite keys in earlier ones. E.g. we pass [:duct.profile/dev :duct.profile/local]
for dev, so that anything in local.edn
overrides the defaults in dev.edn
.
Yeah I am on a version that does not have profiles...
You can pretty trivially rebuild profiles how you want them using duct/merge-configs
. Assuming your version of duct has it.
Just be sure to use the same set of readers.
Thank you sounds good
Does anyone have a pro-tip for getting the raw request body in a duct application? I'm not able to do (slurp (:body request))
as it returns an empty string - I am assuming because it has been consumed by an earlier middleware
How does one tinker with the middleware order in duct? Especially those that are included by default?
:duct.server.http/jetty
{:port #duct/env ["HTTP_SERVER_PORT" Int :or 5000]
:handler #ig/ref :
:logger #ig/ref :duct.logger/timbre}
; ...
:
{:router #ig/ref :duct.router/cascading
:middleware [#ig/ref :my-app.middleware/sentry
#ig/ref :my-app.middleware/bind-db
#ig/ref :my-app.middleware.session/bind-session
#ig/ref :duct.middleware.web/not-found
#ig/ref :duct.middleware.web/webjars
#ig/ref :duct.middleware.web/format
#ig/ref :duct.middleware.web/defaults
#ig/ref :duct.middleware.web/log-requests
#ig/ref :duct.middleware.web/log-errors
#ig/ref :my-app.middleware/error-middleware]}
Thank you so much. This got me to the correct solution. I may be on a newer/older version - but it was enough to reorder only the relevant pieces:
:duct.handler/root
{:middleware [#ig/ref :web.middleware/cors
#ig/ref :duct.middleware.web/not-found
#ig/ref :duct.middleware.web/format
#ig/ref :duct.middleware.web/defaults
#ig/ref :web.middleware/raw-body]}