How to open http logging? #154
-
In |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
hey, that means you could just do something like this while using skrape{it} library: fun main() {
val responseBody = skrape(HttpFetcher) {
request {
url = "https://mvnrepository.com/artifact/kotlin"
also {
// the instantiated request object will be available as an implicit receiver / variable called `it` inside of the also lambda function
println("try to ${it.method} url: ${it.url}")
println("request-headers: ${it.headers}")
// do what ever you want here - maybe use a logger intead of println or trigger some other side effects
}
}
extract {
responseBody
}
}
println(responseBody)
} When you see i hope this helps :) if you like the project don't hesitate to give it a star to support it 🌟 |
Beta Was this translation helpful? Give feedback.
hey,
with kotlin you can do even better. no need to writing a decorator like in java.
if understood correct you want to do something with the instantiated request object.
to do so you can just use kotlin build-in scope function called
also
to execute an additional effect on somerthing. (have a look here for more info).that means you could just do something like this while using skrape{it} library: