r/SpringBoot • u/harry9656 • Dec 17 '24
Using the New RestClient in Spring 6
I recently started using the new RestClient API in Spring 6.1 to handle HTTP requests, and I found it very easy to use.
I used to rely on, which doesn't fit the same style of the WebClient. But using the WebClient doesn't make sense to me in the synchronous HTTP requests as it is just an overkill. It RestClient seems very clean and follows the same fluent API.
I wrote a quick guide on how to use it.
I made a practical example of using OpenAI ChatGPT completion using Rest Api.
What is your opinion on the new RestClient?
3
u/username-345 Dec 18 '24
Good to know if you’re using oauth that in spring 3.4 they’ve launched an oauth interceptor you can use in your builder which didn’t exist before.
0
2
Dec 22 '24 edited Apr 17 '26
Data Brokers don't stand a chance because I mass delete all of my content using Redact - No AI training on my data, thank you very much.
ten rainstorm subtract attraction cats acorn lip roll fine bag
1
u/harry9656 Dec 27 '24
If you already have OpenAPI spec, why not directly generate the REST API code using openapi-generator or similar?
2
Dec 28 '24 edited Apr 17 '26
This post was mass deleted using Redact - Redact also supports Discord, Twitter, Facebook, Instagram and all major social media platforms.
whole marry dam mysterious intelligent offbeat degree voracious groovy dolls
2
u/harry9656 Dec 28 '24
I got it. You are directly generating the FeignClient interfaces with Openfeign. Yeah, I've played with Feign to work with both XML and JSON, but I never used it extensively.
3
u/Acceptable_Bedroom92 Dec 18 '24
Thanks for sharing, I enjoyed the article and learned a little bit about how it works.
1
9
u/zeletrik Dec 18 '24
The “new” RestClient, which is available for around a year now.
RestClient is good while you don’t care about blocking I/O, if you do then WebClient is the way to go