Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaler committed Jul 9, 2024
1 parent 2e29cb5 commit c10d32c
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/kotlin/com/github/djaler/evilbot/config/RestConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.ktor.client.plugins.api.createClientPlugin
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.plugins.observer.ResponseObserver
import io.ktor.client.statement.bodyAsText
import io.ktor.client.statement.request
import io.ktor.http.ContentType
Expand All @@ -20,7 +21,7 @@ import org.springframework.context.annotation.Configuration
class RestConfig {
@Bean
fun httpClient(objectMapper: ObjectMapper): HttpClient {
return HttpClient {
val httpClient = HttpClient {
install(ContentNegotiation) {
register(ContentType.Any, JacksonConverter(objectMapper))
}
Expand All @@ -32,7 +33,23 @@ class RestConfig {
}

install(SentryPlugin)

install(ResponseObserver) {
onResponse {response ->
val request = response.request
Sentry.addBreadcrumb(
Breadcrumb.http(
request.url.toString(),
request.method.value
).apply {
setData("content", response.bodyAsText())
}
)
}
}
}

return httpClient
}
}

Expand All @@ -47,16 +64,4 @@ val SentryPlugin = createClientPlugin("SentryPlugin") {
}
)
}

onResponse {response ->
val request = response.request
Sentry.addBreadcrumb(
Breadcrumb.http(
request.url.toString(),
request.method.value
).apply {
setData("response", response.bodyAsText())
}
)
}
}

0 comments on commit c10d32c

Please sign in to comment.