Package org.springframework.vault.client
Interface ReactiveVaultClient.RequestHeadersSpec<S extends ReactiveVaultClient.RequestHeadersSpec<S>>
- Type Parameters:
S- a self reference to the spec type
- All Known Subinterfaces:
ReactiveVaultClient.RequestBodySpec,ReactiveVaultClient.RequestHeadersBodyPathSpec,ReactiveVaultClient.RequestHeadersPathSpec<S>
- Enclosing interface:
- ReactiveVaultClient
public static interface ReactiveVaultClient.RequestHeadersSpec<S extends ReactiveVaultClient.RequestHeadersSpec<S>>
Contract for specifying request headers leading up to the exchange.
-
Method Summary
Modifier and TypeMethodDescription<V> Flux<V>exchangeToFlux(Function<ClientResponse, ? extends Flux<V>> responseHandler) An alternative toretrieve()that provides more control via access to theClientResponse.<V> Mono<V>exchangeToMono(Function<ClientResponse, ? extends Mono<V>> responseHandler) An alternative toretrieve()that provides more control via access to theClientResponse.Add the given, single header value under the given name.headers(Consumer<HttpHeaders> headersConsumer) Provides access to every header declared so far with the possibility to add, replace, or remove values.headers(HttpHeaders httpHeaders) Add or replace the given headers.default SSet the namespace for this request.retrieve()Enter the retrieve workflow and use the returnedReactiveVaultClient.ResponseSpecto select from a number of built-in options to extract the response.default Stoken(VaultToken token) Set the authentication token for this request.
-
Method Details
-
namespace
Set the namespace for this request.- Parameters:
namespace- the namespace value.- Returns:
- this builder.
-
token
Set the authentication token for this request.- Parameters:
token- the Vault token.- Returns:
- this builder.
-
header
Add the given, single header value under the given name.- Parameters:
headerName- the header name.headerValues- the header value(s).- Returns:
- this builder
-
headers
Add or replace the given headers.- Parameters:
httpHeaders- the headers to be applied.- Returns:
- this builder.
-
headers
Provides access to every header declared so far with the possibility to add, replace, or remove values.- Parameters:
headersConsumer- the consumer to provide access to.- Returns:
- this builder.
-
retrieve
Enter the retrieve workflow and use the returnedReactiveVaultClient.ResponseSpecto select from a number of built-in options to extract the response. For example:Mono<ResponseEntity<Person>> entityMono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .toEntity(Person.class);Or if interested only in the body:
Mono<Person> entityMono = client.get() .uri("/persons/1") .accept(MediaType.APPLICATION_JSON) .retrieve() .bodyToMono(Person.class);By default, 4xx and 5xx responses result in a
VaultClientResponseException. To customize error handling, useonStatushandlers.- Returns:
ResponseSpecto specify how to decode the body.
-
exchangeToMono
An alternative toretrieve()that provides more control via access to theClientResponse. This can be useful for advanced scenarios, for example to decode the response differently depending on the response status:Mono<Person> entityMono = client.get() .path("/persons/1") .accept(MediaType.APPLICATION_JSON) .exchangeToMono(response -> { if (response.statusCode().equals(HttpStatus.OK)) { return response.bodyToMono(Person.class); } else { return response.createError(); } });Note: After the returned
Monocompletes, the response body is automatically released if it hasn't been consumed. If the response content is needed, the provided function must declare how to decode it.- Type Parameters:
V- the type of Object the response will be transformed to.- Parameters:
responseHandler- the function to handle the response with.- Returns:
- a
Monoproduced from the response.
-
exchangeToFlux
An alternative toretrieve()that provides more control via access to theClientResponse. This can be useful for advanced scenarios, for example to decode the response differently depending on the response status:Flux<Person> entityMono = client.get() .path("/persons") .accept(MediaType.APPLICATION_JSON) .exchangeToFlux(response -> { if (response.statusCode().equals(HttpStatus.OK)) { return response.bodyToFlux(Person.class); } else { return response.createError().flux(); } });Note: After the returned
Fluxcompletes, the response body is automatically released if it hasn't been consumed. If the response content is needed, the provided function must declare how to decode it.- Type Parameters:
V- the type of Objects the response will be transformed to.- Parameters:
responseHandler- the function to handle the response with.- Returns:
- a
Fluxof Objects produced from the response.
-