dotnetcore / CAP

Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
http://cap.dotnetcore.xyz
MIT License
6.61k stars 1.28k forks source link

Add option for controlling reponse headers from OnSubscribeExecuted #1541

Closed apatozi closed 2 months ago

apatozi commented 3 months ago

I found a use case that cannot be fulfilled by current options. When using request/response model by supplying the callback name, you cannot add or edit headers to your response. I tried using OnSubscribeExecuted filter to try set the headers for the case where response was not null but there was no documented way to do this. For the moment we did a workaround to set the cap-callback-name to null in that filter to not let cap respond automatically and at the subscriber we published the response with the topic read from the cap-callback-name header, but it feels hacky. It would be useful to add this functionality natively in the library.

yang-xiaodong commented 3 months ago

Hi,

Thanks for your feedback.

We added additional methods for CapHeader to allow controlling the response header, see the docs

https://cap.dotnetcore.xyz/user-guide/en/cap/messaging/#controlling-callback-response

yang-xiaodong commented 3 months ago

Fixed in version 8.2.0-preview-234883029