How To Log Outgoing HTTP Requests with Spring Rest Client and Spring Boot 3

preview_player
Показать описание
When communicating with external APIs, we often use a RestTemplate, WebClient, or RestClient. All of these can be instrumented to log the requests they are sending so we can look into them and ensure they look how we expect them to.

This tutorial shows how to write a custom interceptor to inspect HTTP requests performed with the new RestClient.

⛩️ *Navigation*
00:00 - Intro
00:11 - Let's Code
00:33 - Add the RestClient
00:59 - Add the logging ClientHttpRequestInterceptor
05:13 - Add the interceptor to the RestClient

🍃 *Code & Resources*

🙌 *Get in Touch*

🎙 *Gear & Links*

_I may earn a small commission for purchases made through the links above at no additional cost to you._

🎶 *Music*

🍿 *Subscribe*
Want to see more tech tutorials? Subscribe now!
Рекомендации по теме
Комментарии
Автор

I guess this doesn't work properly.
If you consume the body input stream within the response logging method,
it will fail if trying to consume the body later on. At least I couldn't figure out how to reset the input stream to the beginning.
In your example, you use bodiless() on the client so no body consuming in the app.

blindbyte
Автор

How is the IDE working? I mean you get recommendation for code. Is this a plugin?

TutorialStation
Автор

Is rest client for api integration production ready spring boot?

seyhaphan