Skip to content

Exception while adding custom response headers from feign  #2523

Open

Description

@banupriya2022

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?

Activity

  1. kdavisk6 commented on Sep 11, 2024

    @kdavisk6
    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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feedback providedFeedback has been provided to the author

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions