From 5cb3ea228e9c76661f7c187e2b964eccd94ab924 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Tue, 13 May 2025 15:33:38 +0100 Subject: [PATCH] Polishing in RestClient reference docs --- .../ROOT/pages/integration/rest-clients.adoc | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/integration/rest-clients.adoc b/framework-docs/modules/ROOT/pages/integration/rest-clients.adoc index 0f23a35d0e..48e04dac47 100644 --- a/framework-docs/modules/ROOT/pages/integration/rest-clients.adoc +++ b/framework-docs/modules/ROOT/pages/integration/rest-clients.adoc @@ -12,17 +12,24 @@ The Spring Framework provides the following choices for making calls to REST end [[rest-restclient]] == `RestClient` -The `RestClient` is a synchronous HTTP client that offers a modern, fluent API. -It offers an abstraction over HTTP libraries that allows for convenient conversion from a Java object to an HTTP request, and the creation of objects from an HTTP response. +`RestClient` is a synchronous HTTP client that provides a fluent API to perform requests. +It serves as an abstraction over HTTP libraries, and handles conversion of HTTP request and response content to and from higher level Java objects. -=== Creating a `RestClient` +=== Create a `RestClient` -The `RestClient` is created using one of the static `create` methods. -You can also use `builder()` to get a builder with further options, such as specifying which HTTP library to use (see <>) and which message converters to use (see <>), setting a default URI, default path variables, default request headers, or `uriBuilderFactory`, or registering interceptors and initializers. +`RestClient` has static `create` shortcut methods. +It also exposes a `builder()` with further options: -Once created (or built), the `RestClient` can be used safely by multiple threads. +- select the HTTP library to use, see <> +- configure message converters, see <> +- set a baseUrl +- set default request headers, cookies, path variables +- register interceptors +- register request initializers -The following sample shows how to create a default `RestClient`, and how to build a custom one. +Once created, a `RestClient` is safe to use in multiple threads. + +The below shows how to create or build a `RestClient`: [tabs] ====== @@ -63,17 +70,17 @@ Kotlin:: ---- ====== -=== Using the `RestClient` +=== Use the `RestClient` -When making an HTTP request with the `RestClient`, the first thing to specify is which HTTP method to use. -This can be done with `method(HttpMethod)` or with the convenience methods `get()`, `head()`, `post()`, and so on. +To perform an HTTP request, first specify the HTTP method to use. +Use the convenience methods like `get()`, `head()`, `post()`, and others, or `method(HttpMethod)`. ==== Request URL -Next, the request URI can be specified with the `uri` methods. -This step is optional and can be skipped if the `RestClient` is configured with a default URI. +Next, specify the request URI with the `uri` methods. +This is optional, and you can skip this step if you configured a baseUrl through the builder. The URL is typically specified as a `String`, with optional URI template variables. -The following example configures a GET request to `https://example.com/orders/42`: +The following shows how to perform a request: [tabs] ======