Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception while adding custom response headers from feign #2523

Open
banupriya2022 opened this issue Aug 26, 2024 · 1 comment
Open

Exception while adding custom response headers from feign #2523

banupriya2022 opened this issue Aug 26, 2024 · 1 comment
Labels
feedback provided Feedback has been provided to the author

Comments

@banupriya2022
Copy link

I am looking for enriching the response headers of feign with custom key-value pair through custom ResponseInterceptor class.
However, I am facing UnsupportedOperationException due to UnmodifiableMap.

How do we achieve adding custom response headers with minimal code changes to our microservice?

@kdavisk6
Copy link
Member

First and foremost, Feign is not a replacement or proxy for real HTTP clients. It's meant to reduce boilerplate and simplify integrations with HTTP-like services, so direct modification of Request and Response internal objects is intentionally difficult.

With that said, you have two options:

  • Use a ResponseMapper. This will allow you to mutate the response before decoding, but after intercepting.
  • Create a custom Client implementation that decorates the original HTTP Response headers before the internal Response object is created.

@kdavisk6 kdavisk6 added feedback provided Feedback has been provided to the author labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback provided Feedback has been provided to the author
Projects
None yet
Development

No branches or pull requests

3 participants
@kdavisk6 @banupriya2022 and others