You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/integration/rest-clients.adoc
+20-13Lines changed: 20 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -12,17 +12,24 @@ The Spring Framework provides the following choices for making calls to REST end
12
12
[[rest-restclient]]
13
13
== `RestClient`
14
14
15
-
The `RestClient` is a synchronous HTTP client that offers a modern, fluent API.
16
-
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.
15
+
`RestClient` is a synchronous HTTP client that provides a fluent API to perform requests.
16
+
It serves as an abstraction over HTTP libraries, and handles conversion of HTTP request and response content to and from higher level Java objects.
17
17
18
-
=== Creating a `RestClient`
18
+
=== Create a `RestClient`
19
19
20
-
The `RestClient` is created using one of the static `create` methods.
21
-
You can also use `builder()` to get a builder with further options, such as specifying which HTTP library to use (see <<rest-request-factories>>) and which message converters to use (see <<rest-message-conversion>>), setting a default URI, default path variables, default request headers, or `uriBuilderFactory`, or registering interceptors and initializers.
20
+
`RestClient` has static `create` shortcut methods.
21
+
It also exposes a `builder()` with further options:
22
22
23
-
Once created (or built), the `RestClient` can be used safely by multiple threads.
23
+
- select the HTTP library to use, see <<rest-request-factories>>
24
+
- configure message converters, see <<rest-message-conversion>>
25
+
- set a baseUrl
26
+
- set default request headers, cookies, path variables
27
+
- register interceptors
28
+
- register request initializers
24
29
25
-
The following sample shows how to create a default `RestClient`, and how to build a custom one.
30
+
Once created, a `RestClient` is safe to use in multiple threads.
31
+
32
+
The below shows how to create or build a `RestClient`:
26
33
27
34
[tabs]
28
35
======
@@ -63,17 +70,17 @@ Kotlin::
63
70
----
64
71
======
65
72
66
-
=== Using the `RestClient`
73
+
=== Use the `RestClient`
67
74
68
-
When making an HTTP request with the `RestClient`, the first thing to specify is which HTTP method to use.
69
-
This can be done with `method(HttpMethod)` or with the convenience methods `get()`, `head()`, `post()`, and so on.
75
+
To perform an HTTP request, first specify the HTTP method to use.
76
+
Use the convenience methods like `get()`, `head()`, `post()`, and others, or `method(HttpMethod)`.
70
77
71
78
==== Request URL
72
79
73
-
Next, the request URI can be specified with the `uri` methods.
74
-
This step is optional and can be skipped if the `RestClient` is configured with a default URI.
80
+
Next, specify the request URI with the `uri` methods.
81
+
This is optional, and you can skip this step if you configured a baseUrl through the builder.
75
82
The URL is typically specified as a `String`, with optional URI template variables.
76
-
The following example configures a GET request to `https://example.com/orders/42`:
0 commit comments