This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-14
Channels
- # announcements (3)
- # babashka-sci-dev (22)
- # beginners (6)
- # calva (36)
- # cljsrn (1)
- # clojure (59)
- # clojure-europe (31)
- # clojure-france (3)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-uk (4)
- # clojurescript (6)
- # conjure (1)
- # cursive (11)
- # data-oriented-programming (1)
- # datahike (2)
- # docker (8)
- # duct (4)
- # emacs (1)
- # figwheel-main (5)
- # kaocha (1)
- # leiningen (8)
- # lsp (64)
- # malli (10)
- # membrane (5)
- # nrepl (11)
- # off-topic (5)
- # portal (6)
- # quil (9)
- # reagent (62)
- # reitit (15)
- # releases (3)
- # ring-swagger (2)
- # shadow-cljs (36)
- # specter (2)
- # tools-deps (21)
Hi all! Is it possible to have some sort of duct component or module that does post-processing of the payload returned by another handler? I'm trying to do something like this:
[:money-clip.duct.restful/resource :money-clip.handler.bank-accounts/create]
{:db #ig/ref :duct.database/sql
:add {:user-id [:bank-account :user :id]}
:exclude [[:bank-account :user]]
:links {:self "/bank-account/{id}" :user "/users/{user-id}"}}
Where :money-clip.duct.restful/resource
would be a generic post-processor - customisable by the :add
/ :exclude
and :links
options - for the map returned by the :money-clip.handler.bank-accounts/create
handler. But I seem to be getting nowhere with it.
What would be the duct way of achieving this or something similar? Thanks.As it is now, I get the following error
Multiple methods in multimethod 'init-key' match dispatch value: :integrant.composite/money-clip.duct.restful.resource+money-clip.handler.bank-accounts.create_18632 -> :money-clip.handler.bank-accounts/create and :money-clip.duct.restful/resource, and neither is preferred
I can think of 2 ways:
1) Split /resource
and /create
into separate components, such that the former refs the latter:
:money-clip.duct.restful/resource {:create #ig/ref :money-clip.handler.bank-accounts/create}
That way /resource
can post-process the /create
component.
2) Do post-processing in /create
's init-key
method on the component value that would've been returned.Thanks @UJY23QLS1! Will definitely explore those two options.