Skip to content

Commit

Permalink
Support Rest Client
Browse files Browse the repository at this point in the history
  • Loading branch information
raynigon committed Nov 28, 2024
1 parent a8fb55f commit c0bb1f0
Showing 1 changed file with 29 additions and 0 deletions.
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);
});
}
}

0 comments on commit c0bb1f0

Please sign in to comment.