Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Update documentation regarding Config Data API customization.

See spring-cloudgh-662
  • Loading branch information
mp911de committed Mar 2, 2023
1 parent e66a502 commit b132a25
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions docs/src/main/asciidoc/config-data.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,36 @@ Spring Boot bootstraps the application before a Spring Context is available. The

You can customize the infrastructure used by Spring Cloud Vault by registering custom instances using the `Bootstrapper` API:

.Customizing `ClientHttpRequestFactory`
====
[source,java]
----
InstanceSupplier<RestTemplateBuilder> builderSupplier = ctx -> RestTemplateBuilder
.builder()
.requestFactory(ctx.get(ClientFactoryWrapper.class).getClientHttpRequestFactory())
.defaultHeader("X-Vault-Namespace", "my-namespace");
ClientOptions options = new ClientOptions();
SslConfiguration sslConfiguration = SslConfiguration.unconfigured();
HttpClientBuilder builder = HttpComponents.getHttpClientBuilder(options, sslConfiguration);
InstanceSupplier<ClientFactoryWrapper> supplier = context ->
new ClientFactoryWrapper(new HttpComponentsClientHttpRequestFactory(builder.build()));
SpringApplication application = new SpringApplication(MyApplication.class);
application.addBootstrapRegistryInitializer(registry -> registry.register(ClientFactoryWrapper.class, supplier));
----
====

.Customizing `RestTemplateBuilder`
====
[source,java]
----
InstanceSupplier<RestTemplateBuilder> supplier = context -> {
return RestTemplateBuilder
.builder()
.requestFactory(context.get(ClientFactoryWrapper.class).getClientHttpRequestFactory())
.defaultHeader("X-Vault-Namespace", "my-namespace");
};
SpringApplication application = new SpringApplication(MyApplication.class);
application.addBootstrapper(registry -> registry.register(RestTemplateBuilder.class, builderSupplier));
application.addBootstrapRegistryInitializer(registry -> registry.register(RestTemplateBuilder.class, supplier));
----
====

Expand Down

0 comments on commit b132a25

Please sign in to comment.