-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...-access/src/main/java/com/raynigon/ecs/logging/access/client/RestClientConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.raynigon.ecs.logging.access.client; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.web.client.RestClientCustomizer; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpRequest; | ||
import org.springframework.http.client.ClientHttpRequestExecution; | ||
import org.springframework.web.client.RestClient; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
@AutoConfiguration | ||
@RequiredArgsConstructor | ||
@ConditionalOnClass(value = {RestClient.Builder.class}) | ||
public class RestClientConfiguration implements RestClientCustomizer { | ||
|
||
@Override | ||
public void customize(RestClient.Builder restClientBuilder) { | ||
restClientBuilder.requestInterceptor((request, body, execution) -> { | ||
new AccessLogHeaderFilter().accept(request.getHeaders()); | ||
return execution.execute(request, body); | ||
}); | ||
} | ||
} |