0

I am writing an app in which I want to enrich an outgoing request based on some configuration. Configuration example

clients:
  clientA:
    header1: value1
    header2: value2
  client2:
    header1: value3
    header2: value4

To do that I have two goals:

  • Extend the native configuration to be able to add the more information
  • In a ClientFilter, retrieve this information and add to the request

Talking about the second point: 1- Is there a way that I get the clientId of the client making the request on the filter? Or can I inject the client itself? 2- Is there a way for me to load the appropriate configuration based on the clientId?

JSBach
  • 4,679
  • 8
  • 51
  • 98
  • Can you expand on what you mean by "enrich an outgoing request"? Depending on what you want to do, a filter may not be the only or best option. – Jeff Scott Brown Aug 11 '20 at 15:22
  • @JeffScottBrown sorry for the delay. The idea is the following: my system makes http requests against other systems. Depending on the client, I should either use a token generated for my app or I should delegate the user's token for authentication on the target service. I want to use the filter to add the token to the outgoing request. – JSBach Sep 03 '20 at 20:00

1 Answers1

0

Solution: There is a request attribute indicating that:

request.getAttribute("micronaut.http.serviceId")
JSBach
  • 4,679
  • 8
  • 51
  • 98