enleur
08/27/2018, 11:27 AMDeactivated User
08/27/2018, 11:32 AMval MyAttributeKey = AttributeKey<Int>("MyAttributeKey")
call.attributes.put(MyAttributeKey, 10)
call.attributes.get(MyAttributeKey)
Deactivated User
08/27/2018, 11:34 AMApplicationCall
contains a attributes
property that acts as a small typed dependency injector/instance container bounded to the call (so its lifespan is between the request until the response is completed).
You can put any attribute you want in an interceptor that executes before, and then receive it later in another interceptorDeactivated User
08/27/2018, 11:53 AMenleur
08/27/2018, 12:08 PMHttpClientCall
used for ktor client?enleur
08/27/2018, 12:08 PMHttpRequestBuilder.setAttributes
, but not sure if it works at allenleur
08/27/2018, 12:09 PMinstall("MyFeature") {
sendPipeline.intercept(HttpSendPipeline.Before) {
this.context.setAttributes {
put(key, 1)
}
}
}
Deactivated User
08/27/2018, 12:13 PMattributes
property, but let me checkDeactivated User
08/27/2018, 12:14 PMDeactivated User
08/27/2018, 12:15 PMHttpRequest
interface also has an attributesDeactivated User
08/27/2018, 12:16 PMcall.request.attributes
?enleur
08/27/2018, 12:34 PMsendPipeline
or requestPipeline
Deactivated User
08/27/2018, 12:34 PMenleur
08/27/2018, 12:37 PMPipelineContext<Any, RequestBuilder>
is used inside interceptors
so i can use HttpRequestBuilder
but don’t see any way to get to the HttpRequest
enleur
08/27/2018, 12:37 PMreceivePipeline
thoenleur
08/27/2018, 12:38 PMDeactivated User
08/27/2018, 12:38 PMDeactivated User
08/27/2018, 12:39 PMenleur
08/27/2018, 12:41 PMprocess()
with before/after timestamps. And in the end log all this data with extra info, passed in the beginning and total timee5l
08/27/2018, 12:42 PMHttpRequestBuilder.setAttribute
to mark the request? You could get request from the response using call
field.enleur
08/27/2018, 12:49 PMsetAttribute
but it was never called
how can i get call
field inside requestPipeline
?enleur
08/27/2018, 12:51 PMreceivePipeline.intercept(HttpReceivePipeline.Before) {
println(context.request.attributes.takeOrNull(key))
}
I also tried this, but it’s still empty and setAttribute
was not callede5l
08/27/2018, 12:51 PMenleur
08/27/2018, 12:55 PM