All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rebue.wheel.vertx.guice.WebClientGuiceModule Maven / Gradle / Ivy

The newest version!
package rebue.wheel.vertx.guice;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;

import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class WebClientGuiceModule extends AbstractModule {

    public WebClientGuiceModule() {
        log.info("new WebClientGuiceModule");
    }

    @Singleton
    @Provides
    WebClient getWebClient(final Vertx vertx, @Named("config") final JsonObject config) {
        log.info("WebClientGuiceModule.getWebClient");
        final JsonObject webClientConfig = config.getJsonObject("webClient");
        if (webClientConfig == null) {
            return WebClient.create(vertx);
        }
        return WebClient.create(vertx, new WebClientOptions(webClientConfig));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy