https://kotlinlang.org logo
#ktor
Title
# ktor
l

legzo

04/04/2019, 10:41 AM
Hi guys, I use an Client to make REST calls and I would like to store a value between the request and the response (the goal is to log the elapsed time). I don't really know where I can store this value so that it's available later from a
ResponseObserver
. Do you have any clue ?
e

e5l

04/04/2019, 10:49 AM
You could intercept
request
and
response
pipeline in
State
phase. And store value in attributes
☝️ 2
l

legzo

04/04/2019, 11:33 AM
Ah, that's more or less what I ended up doing : I read the docs a bit more thoroughly and found out the piece about attributes. So in my logging feature (that intercepts at Before phase, I guess it would be better to do it at State phase as you said) I put stuff in
call.request.attributes
. Thanks for the hint !
👍 1
2 Views