diff --git a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfig.kt b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfig.kt index 2b508b11..722dc19d 100644 --- a/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfig.kt +++ b/src/main/kotlin/no/nav/tjenestepensjon/simulering/config/WebClientConfig.kt @@ -12,6 +12,7 @@ import org.slf4j.MDC import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Profile import org.springframework.http.MediaType import org.springframework.http.client.reactive.ReactorClientHttpConnector import org.springframework.web.reactive.function.client.ClientRequest @@ -24,11 +25,18 @@ import reactor.netty.http.client.HttpClient @Configuration class WebClientConfig { + @Profile(value = ["prod", "preprod"]) @Bean fun httpClient(): HttpClient = HttpClient.create().proxyWithSystemProperties().option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS) .doOnConnected { it.addHandlerLast(ReadTimeoutHandler(READ_TIMEOUT_MILLIS / 1000)) } + @Profile(value = ["prod-gcp", "dev-gcp"]) + @Bean + fun client(): HttpClient = + HttpClient.create().option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MILLIS) + .doOnConnected { it.addHandlerLast(ReadTimeoutHandler(READ_TIMEOUT_MILLIS / 1000)) } + @Bean fun webClient(httpClient: HttpClient): WebClient = WebClient.builder().clientConnector(ReactorClientHttpConnector(httpClient))