Colton Idle
05/20/2021, 5:13 AMInterceptors from okhttp library. The thing is that interceptor order matters, and so now I believe that I need to move away from IntoSet into something that allows me to dictate order. Am I missing some other api like @IntoList or something or does this basically mean that I can't/shouldn't use multi bindings for interceptors?ephemient
05/20/2021, 5:34 AM@IntoMap @IntKey(1) etc. for ordering, but I don't think it's a great fitephemient
05/20/2021, 5:35 AMwasyl
05/20/2021, 6:22 AMdata class OrderedInterceptor(val order: Int, val interceptor: Interceptor) and inject Set<OrderedInterceptor>. Then you can provide those with orders e.g. in the range of 0-100, and when adding them to OkHttp do orderedInterceptors.sortedBy { it.order }.forEach { builder.addInterceptor(it.interceptor }trevjones
05/27/2021, 4:08 AMSet<Interceptor> for those that donโt care for ordering. Then for those that do matter on ordering. us an interface.
interface HttpClientConfigVisitor {
/**
* Override to influence visitation ordering.
* Sorting is done in descending order.
*
* Some elements like logging needs to be last in the list so that
* any request mutation happens before the first log entry is created.
* This should ensure the correct request information is logged.
*/
val affinity: Int
get() = Int.MAX_VALUE
fun OkHttpClient.Builder.visit()
}trevjones
05/27/2021, 4:08 AM