Search code examples
helidonhelidon-webclient

Configuring Helidon WebClient for JsonbSupport reader, writer and media support through properties


I want to configure my helidon web-client just using config. Something like below: WebClient.builder() .config(Config.create().get("web-client")).build();

and my config looks like below:

web-client:
  uri:<my-base-uri>
  media-support:
     services: //What should i add here which will be equivalent to below in webclient builder
                .addReader(JsonbSupport.reader())
                .addWriter(JsonbSupport.writer())
                .addMediaSupport(JsonbSupport.create())

I tried following config:

web-client:
  uri:<my-base-uri>
  media-support:
    discover-services: true

It worked but I guess due to default reader/writers. Still I do not understand what will discover-services exactly do and if Json support will be added automatically using above config.


Solution

  • discover-services property means, that Helidon will use service loader to load all MediaSupportProviders present on the classpath.

    If you had this dependency added:

    <dependency>
        <groupId>io.helidon.media</groupId>
        <artifactId>helidon-media-jsonb</artifactId>
    </dependency>
    

    and discover-services enabled, complete Jsonb support was found and registered automatically for you.