Created
November 6, 2021 19:21
-
-
Save murattuzel/d5448e5c383e007c23192be575e74ebb to your computer and use it in GitHub Desktop.
Mock interceptor reads local json file and returns the file as a response.
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 MockRequestInterceptor : Interceptor { | |
override fun intercept(chain: Interceptor.Chain): Response { | |
return with(chain.request()) { | |
when (val mockRequestType = findMockTag()) { | |
is MockRequestType -> createLocalResponse( | |
request = this, | |
filePath = mockRequestType.filePath | |
) | |
else -> chain.proceed(this) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment