package space.nstart.pcp.pcp_satellites_service.configuration

import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.util.unit.DataSize
import org.springframework.web.reactive.function.client.WebClient

@Configuration
class WebClientConfig(
    @param:Value("\${spring.codec.max-in-memory-size:20MB}")
    private val maxInMemorySize: DataSize
) {

    @Bean
    fun webClientBuilder(): WebClient.Builder =
        WebClient.builder()
            .codecs { configurer ->
                configurer.defaultCodecs().maxInMemorySize(maxInMemorySize.toBytes().toInt())
            }
}
