@@ -154,6 +154,17 @@ static RestClient create(String baseUrl) {
154
154
return new DefaultRestClientBuilder ().baseUrl (baseUrl ).build ();
155
155
}
156
156
157
+ /**
158
+ * Variant of {@link #create()} that accepts a default base {@code URI}. For more
159
+ * details see {@link Builder#baseUrl(URI) Builder.baseUrl(URI)}.
160
+ * @param baseUrl the base URI for all requests
161
+ * @since 6.2
162
+ * @see #builder()
163
+ */
164
+ static RestClient create (URI baseUrl ) {
165
+ return new DefaultRestClientBuilder ().baseUrl (baseUrl ).build ();
166
+ }
167
+
157
168
/**
158
169
* Create a new {@code RestClient} based on the configuration of the given
159
170
* {@code RestTemplate}.
@@ -230,6 +241,26 @@ interface Builder {
230
241
*/
231
242
Builder baseUrl (String baseUrl );
232
243
244
+ /**
245
+ * Configure a base {@code URI} for requests. Effectively a shortcut for:
246
+ * <pre class="code">
247
+ * URI baseUrl = URI.create("https://abc.go.com/v1");
248
+ * DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl.toString());
249
+ * RestClient client = RestClient.builder().uriBuilderFactory(factory).build();
250
+ * </pre>
251
+ * <p>The {@code DefaultUriBuilderFactory} is used to prepare the URL
252
+ * for every request with the given base URL, unless the URL request
253
+ * for a given URL is absolute in which case the base URL is ignored.
254
+ * <p><strong>Note:</strong> this method is mutually exclusive with
255
+ * {@link #uriBuilderFactory(UriBuilderFactory)}. If both are used, the
256
+ * {@code baseUrl} value provided here will be ignored.
257
+ * @return this builder
258
+ * @since 6.2
259
+ * @see DefaultUriBuilderFactory#DefaultUriBuilderFactory(String)
260
+ * @see #uriBuilderFactory(UriBuilderFactory)
261
+ */
262
+ Builder baseUrl (URI baseUrl );
263
+
233
264
/**
234
265
* Configure default URL variable values to use when expanding URI
235
266
* templates with a {@link Map}. Effectively a shortcut for:
@@ -414,7 +445,11 @@ Builder defaultStatusHandler(Predicate<HttpStatusCode> statusPredicate,
414
445
interface UriSpec <S extends RequestHeadersSpec <?>> {
415
446
416
447
/**
417
- * Specify the URI using an absolute, fully constructed {@link URI}.
448
+ * Specify the URI using a fully constructed {@link URI}.
449
+ * <p>If the given URI is absolute, it is used as given. If it is
450
+ * a relative URI, the {@link UriBuilderFactory} configured for
451
+ * the client (e.g. with a base URI) will be used to
452
+ * {@linkplain URI#resolve(URI) resolve} the given URI against.
418
453
*/
419
454
S uri (URI uri );
420
455
0 commit comments