Fork me on GitHub

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:

 {: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 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/ -> 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}
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.