Skip to content

Commit

Permalink
add: Webclient COnfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongho1209 committed Mar 23, 2024
1 parent f28ccdd commit 05489ce
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.trip.safe.common.webclient.configuration

import com.trip.safe.common.logger.logger
import org.slf4j.Logger
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.util.DefaultUriBuilderFactory

@Configuration
class WebClientConfiguration(
@Value("\${service.url}")
private val serviceUrl: String,
) {
private val log: Logger = logger()

@Bean
fun defaultUriFactory() = DefaultUriBuilderFactory(serviceUrl).apply {
encodingMode = DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY
}

@Bean
fun webClient() = WebClient.builder()
.uriBuilderFactory(defaultUriFactory())
.filter { request, next ->
log.info("try to request webclient url : ${request.url()}, method : ${request.method()}")
next.exchange(request)
}
.build()
}

0 comments on commit 05489ce

Please sign in to comment.