Created
July 23, 2020 08:15
-
-
Save khandar-william/fede32e497321429f089833ccb488458 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// RestTemplate interceptor | |
public class CustomRequestInterceptor implements ClientHttpRequestInterceptor { | |
@Override | |
public ClientHttpResponse intercept( | |
final HttpRequest request, | |
final byte[] body, | |
final ClientHttpRequestExecution execution | |
) throws IOException { | |
log.info("INTERCEPT {} {} {} body {}", request.getMethodValue(), request.getURI(), request.getHeaders(), | |
body); | |
final ClientHttpResponse response = execution.execute(request, body); | |
return response; | |
} | |
} | |
// Use: | |
// restTemplate.getInterceptors().add(new CustomRequestInterceptor()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment