io.lsdconsulting.interceptors.http.LsdRestTemplateCustomizer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lsd-interceptors Show documentation
Show all versions of lsd-interceptors Show documentation
Provides various interceptors to capture events for the lsd-core library to generate sequence diagrams
package io.lsdconsulting.interceptors.http
import org.springframework.boot.web.client.RestTemplateCustomizer
import org.springframework.http.client.BufferingClientHttpRequestFactory
import org.springframework.http.client.ClientHttpRequestInterceptor
import org.springframework.http.client.SimpleClientHttpRequestFactory
import org.springframework.web.client.RestTemplate
data class LsdRestTemplateCustomizer(
private var interceptor: ClientHttpRequestInterceptor
) : RestTemplateCustomizer {
override fun customize(restTemplate: RestTemplate) {
val interceptors = restTemplate.interceptors
if (!interceptors.contains(interceptor)) {
interceptors.add(interceptor)
}
restTemplate.requestFactory = BufferingClientHttpRequestFactory(SimpleClientHttpRequestFactory())
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy