How to apply WebClient.attribute on every webflux request?

200
July 25, 2019, at 04:20 AM

I have a WebClient created with WebClient.Builder from spring-webflux.

I want to hand over a specific parameter (here MDC.get("uuid")) into every request that is executed using that WebClient. It could be done as follows:

webClient.get().attribute(ClientRequest.LOG_ID_ATTRIBUTE, MDC.get("uuid"))....block();

But: I'd prefer adding this attribute already during the WebClient.Builder process, eg as an ExchangeFilter or similar. So that every class that makes use of my default common builder will automatically set this attribute, without having to call it explicit on each web request.

Is that possible?

Rent Charter Buses Company
READ ALSO
Replacing an annotation with another annotation during compile time in Spring?

Replacing an annotation with another annotation during compile time in Spring?

I am using Swagger annotations over my controller parametersSo, I end up with annotations like @ApiParam(name="default name", value="this is a default value")

115
Struggling to convert an Object to have keys within one of the sub objects

Struggling to convert an Object to have keys within one of the sub objects

I'm struggling to convert this file so that the clientID is the key on the Object within 'things'I want to flatten the array and then have keys for each Object within an outer Object

98
in the following code can we return the same thing without using the place variable, if yes how?

in the following code can we return the same thing without using the place variable, if yes how?

this function filters the cities array according to the condition that they should match the wordToMatch and is part of ajaxi tried using console

118
Inheriting attributes from prototype

Inheriting attributes from prototype

I am working on a school assignment and I want to inherit the properties of a previous constructor functionI used object

106