How to open http logging? #154
|
In |
Answered by
christian-draeger
Jun 28, 2021
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 🌟 |
0 replies
Answer selected by
christian-draeger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
alsoto 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: