Merge pull request #239 from usbharu/feature/user-agent

feat: ActivityPubの通信に使うHTTPクライアントのUserAgentを設定
This commit is contained in:
usbharu 2024-01-16 14:57:17 +09:00 committed by GitHub
commit afbddad21b
2 changed files with 12 additions and 2 deletions

View File

@ -316,3 +316,7 @@ koverReport {
}
}
}
springBoot {
buildInfo()
}

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})"
}
}
}