Last active
October 13, 2022 18:02
-
-
Save yongjhih/cf5940d922e9964a601559d98a511d0c to your computer and use it in GitHub Desktop.
Retrofit Annotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class InterceptedInterceptor : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response = | |
try { | |
val invocation = chain.request().tag<Invocation>() | |
val annotation = invocation?.method()?.annotation<Intercepted>() | |
(annotation?.value?.java?.constructors?.first() | |
?.newInstance(invocation.arguments()) as Interceptor?)?.intercept(chain) | |
} catch (e: Throwable) { null } ?: chain.proceed(chain.request()) | |
} |
Author
yongjhih
commented
Oct 13, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment