Hi everyone is the the right place to ask question...
# ktor
r
Hi everyone is the the right place to ask questions about Ktor Client? If Yes then please help me figuring out the same. while migrating from Retrofit to Ktor Client I'm stuck at the below problem. How can I add a header whose value is dependent upon the instance of the ongoing request? like with retrofit I used an Interceptor which provided me with the instance of the ongoing request and with that instance I created a Hash and attached the same to the request as header. How can I achieve the same with Ktor header("Hash-value", someFunctionToGenerateHash(request))
s
You can create a plugin and use the onRequest callback for this: https://ktor.io/docs/client-custom-plugins.html#first-plugin
The example here does almost exactly what you're asking
a
How is the request used to calculate the hash? Does the request body participate in the calculation?