I have quite unusual use case where I need to pass same "dynamic" value as two different headers. Which more or less looks like this:

    @GetMapping(path = "/opportunity/{opportunityId}", headers = ["X-ActorRole=CUSTOMER"])
    void getOpportunity(
            @PathVariable("opportunityId") String opportunityId,
            @RequestHeader("X-ActorId") Long customerId,
            @RequestHeader("X-Auth-Uid") Long customerId2
    )

This creates quite ugly API where on call site I need to pass twice the same id as param. I know I could use @RequestHeader Map<String, String> headerMap, but this moves responsibility of knowing how to setup headers to a call site and I would like to avoid it. In Feign this is not a problem because you can put @Headers annotation with two separate headers with same param.

I'm not sure if it's feasible but I was thinking about using SpEL in headers section of @RequestMapping annotation to get the value of a param. This could look like:

    @GetMapping(path = "/opportunity/{opportunityId}", headers = ["X-ActorRole=CUSTOMER", "X-Auth-Uid=#{customerId}"])
    void getOpportunity(
            @PathVariable("opportunityId") String opportunityId,
            @RequestHeader("X-ActorId") Long customerId
    )

From my checks SpEL seem not to be evaluated for headers right now, but this would give us freedom also to setup static headers from configuration and many other future use cases.

I'm not sure it this is good idea, but let me know what you think!

Comment From: OlgaMaciaszek

Hello, @Krotki Thanks for proposing it. Due to it being a rather rare scenario with available workarounds, I don't think this is something that we will want to add to our backlog at this point.