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

divyanshunegi

06/12/2021, 5:33 PM
This might sound a noob question but just starting on KMM, I want to create an APIClient as shared module for Android and iOS I need the following features in my
Ktor
Implementation. • It should have local SSL data encryption • InternetConnectionCheck Interceptor • ErrorHandlerInterceptor • RetryRequest After RefreshToken Interceptor • Few other custom interceptors Earlier I was writing my APiClient in the
commonMain
but as I can see it does not support addInterceptor property by default, which is available in OkHttp for Android. So the new plan I had is create an expect class APiClient in common main and implement APIClient for Android on AndroidMain with OkHttp engine and APiClient on iOSMain with IOS Engine. Is this approach right ? or am I missing some part ?
x

xxfast

06/13/2021, 2:19 AM
it’ll be less work if you keep your interceptors within
commonMain
by utilising ktor plugins for this. Although, i’m not sure how functionally different ktor plugins are for okhttp interceptors
6 Views