Attempting to fix black magic 2

This commit is contained in:
bskjon 2025-02-23 03:24:36 +01:00
parent b02b0ce05b
commit 4955e49f54

View File

@ -54,15 +54,13 @@ class WebConfig: WebMvcConfigurer {
class ApiCommunicationConfig { class ApiCommunicationConfig {
@Bean @Bean
fun coordinatorTemplate(): RestTemplate { fun coordinatorTemplate(builder: RestTemplateBuilder): RestTemplate {
return try { return try {
val url = UIEnv.coordinatorUrl val url = UIEnv.coordinatorUrl
log.info { "CoordinatorUrl: $url" } log.info { "CoordinatorUrl: $url" }
require(url.isNotBlank()) { "UIEnv.coordinatorUrl er ikke satt!" } require(url.isNotBlank()) { "UIEnv.coordinatorUrl er ikke satt!" }
builder.uriTemplateHandler(DefaultUriBuilderFactory(url))
val restTemplate = RestTemplate() builder.build()
restTemplate.uriTemplateHandler = DefaultUriBuilderFactory(url)
restTemplate
} catch (e: Exception) { } catch (e: Exception) {
throw IllegalStateException("Feil ved opprettelse av coordinatorTemplate: ${e.message}", e) throw IllegalStateException("Feil ved opprettelse av coordinatorTemplate: ${e.message}", e)
} }