Skip to content

Update documentation for HTTP Interface return values #30959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 45 additions & 14 deletions framework-docs/modules/ROOT/pages/integration/rest-clients.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -495,45 +495,76 @@ method parameters:
[[rest-http-interface-return-values]]
=== Return Values

Annotated, HTTP exchange methods support the following return values:
The supported return values vary depending on whether you are using
`HttpExchangeAdapter` or `ReactorHttpExchangeAdapter`.

When using `HttpExchangeAdapter`, annotated HTTP exchange methods support
the following return values:

[cols="1,2", options="header"]
|===
| Method return value | Description

| `void`, `Mono<Void>`
| `void`
| Perform the given request.

| `HttpHeaders`
| Perform the given request and return the response headers.

| `<T>`
| Perform the given request and decode the response content to the declared return type.

| `ResponseEntity<Void>`
| Perform the given request and return a `ResponseEntity` with the status and headers.

| `ResponseEntity<T>`
| Perform the given request, decode the response content to the declared return type, and
return a `ResponseEntity` with the status, headers, and the decoded body.

|===

When using `ReactorHttpExchangeAdapter`, annotated HTTP exchange methods support
all the same values as the ones supported by `HttpExchangeAdapter`
and also the following ones:

[cols="1,2", options="header"]
|===
| Method return value | Description

| `Mono<Void>`
| Perform the given request, and release the response content, if any.

| `HttpHeaders`, `Mono<HttpHeaders>`
| `Mono<HttpHeaders>`
| Perform the given request, release the response content, if any, and return the
response headers.
response headers.

| `<T>`, `Mono<T>`
| `Mono<T>`
| Perform the given request and decode the response content to the declared return type.

| `<T>`, `Flux<T>`
| `Flux<T>`
| Perform the given request and decode the response content to a stream of the declared
element type.
element type.

| `ResponseEntity<Void>`, `Mono<ResponseEntity<Void>>`
| `Mono<ResponseEntity<Void>>`
| Perform the given request, and release the response content, if any, and return a
`ResponseEntity` with the status and headers.
`ResponseEntity` with the status and headers.

| `ResponseEntity<T>`, `Mono<ResponseEntity<T>>`
| `Mono<ResponseEntity<T>>`
| Perform the given request, decode the response content to the declared return type, and
return a `ResponseEntity` with the status, headers, and the decoded body.
return a `ResponseEntity` with the status, headers, and the decoded body.

| `Mono<ResponseEntity<Flux<T>>`
| Perform the given request, decode the response content to a stream of the declared
element type, and return a `ResponseEntity` with the status, headers, and the decoded
response body stream.
element type, and return a `ResponseEntity` with the status, headers, and the decoded
response body stream.

|===

TIP: You can also use any other async or reactive types registered in the
`ReactiveAdapterRegistry`.

By default, the behavior of HTTP service methods with synchronous (blocking) method
While using the `ReactorHttpExchangeAdapter`, by default, the behavior
of HTTP service methods with synchronous (blocking) method
signature depends on connection and timeout settings of the underlying HTTP client.
`HttpServiceProxyFactory.Builder` does expose a `blockTimeout` option that also lets you
configure the maximum time to block for a response, but we recommend configuring timeout
Expand Down