feat: ActivityPubの通信に使うHTTPクライアントのUserAgentを設定

This commit is contained in:
usbharu 2024-01-16 14:06:35 +09:00
parent c1e1a4d963
commit 3a89a0942a
1 changed files with 7 additions and 1 deletions

View File

@ -2,15 +2,18 @@ package dev.usbharu.hideout.application.config
import io.ktor.client.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.cache.*
import io.ktor.client.plugins.logging.*
import org.springframework.boot.info.BuildProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class HttpClientConfig {
@Bean
fun httpClient(): HttpClient = HttpClient(CIO).config {
fun httpClient(buildProperties: BuildProperties, applicationConfig: ApplicationConfig): HttpClient =
HttpClient(CIO).config {
install(Logging) {
logger = Logger.DEFAULT
level = LogLevel.ALL
@ -18,5 +21,8 @@ class HttpClientConfig {
install(HttpCache) {
}
expectSuccess = true
install(UserAgent) {
agent = "Hideout/${buildProperties.version} (${applicationConfig.url})"
}
}
}