-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* proxiedWebClientBuilder dras inn i idportenclientConfig og kommuneinfoclientConfig
- Loading branch information
1 parent
91b44af
commit 35e66f9
Showing
10 changed files
with
114 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ class NorgClientImpl( | |
} | ||
} | ||
.bodyToMono<String>() | ||
|
||
.block() | ||
} | ||
|
||
|
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/no/nav/sosialhjelp/innsyn/config/ProxiedWebClientConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package no.nav.sosialhjelp.innsyn.config | ||
|
||
import no.nav.sosialhjelp.innsyn.utils.getReactorClientHttpConnector | ||
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.client.reactive.ReactorClientHttpConnector | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import reactor.netty.http.client.HttpClient | ||
|
||
@Profile("!(mock|mock-alt|local)") | ||
@Configuration | ||
class ProxiedWebClientConfig { | ||
|
||
@Value("\${HTTPS_PROXY}") | ||
private lateinit var proxyUrl: String | ||
|
||
@Bean | ||
fun proxiedWebClientBuilder(): WebClient.Builder = | ||
WebClient.builder() | ||
.clientConnector(getReactorClientHttpConnector(proxyUrl)) | ||
|
||
} | ||
|
||
@Profile("mock|mock-alt|local") | ||
@Configuration | ||
class MockProxiedWebClientConfig { | ||
|
||
@Bean | ||
fun proxiedWebClientBuilder(): WebClient.Builder = | ||
WebClient.builder() | ||
.clientConnector(ReactorClientHttpConnector(HttpClient.newConnection())) | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/no/nav/sosialhjelp/innsyn/config/WebClientConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package no.nav.sosialhjelp.innsyn.config | ||
|
||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.client.reactive.ReactorClientHttpConnector | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import reactor.netty.http.client.HttpClient | ||
|
||
@Configuration | ||
class WebClientConfig( | ||
private val webClientBuilder: WebClient.Builder, | ||
) { | ||
@Bean | ||
fun webClient(): WebClient = | ||
webClientBuilder | ||
.clientConnector(ReactorClientHttpConnector(HttpClient.newConnection())) | ||
.build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/no/nav/sosialhjelp/innsyn/utils/HttpClientUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package no.nav.sosialhjelp.innsyn.utils | ||
|
||
import org.springframework.http.client.reactive.ReactorClientHttpConnector | ||
import reactor.netty.http.client.HttpClient | ||
import reactor.netty.transport.ProxyProvider | ||
import java.net.URL | ||
|
||
fun getReactorClientHttpConnector(proxyUrl: String): ReactorClientHttpConnector { | ||
val uri = URL(proxyUrl) | ||
|
||
val httpClient: HttpClient = HttpClient.create() | ||
.proxy { proxy -> | ||
proxy.type(ProxyProvider.Proxy.HTTP).host(uri.host).port(uri.port) | ||
} | ||
|
||
return ReactorClientHttpConnector(httpClient) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters