You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception while adding custom response headers from feign #2523
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?
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 Responseinternal 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.
Activity
kdavisk6 commentedon Sep 11, 2024
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
RequestandResponseinternal objects is intentionally difficult.With that said, you have two options:
ResponseMapper. This will allow you to mutate the response before decoding, but after intercepting.Clientimplementation that decorates the original HTTP Response headers before the internalResponseobject is created.