Interceptor

fun interface Interceptor

Intercepts network requests to observe, modify or short-circuit requests and their corresponding responses. Typical use cases for interceptors are network request logging, request mocking (for test implementations) or adding/removing/transforming headers on the request.

An interceptor is created and configured by creating a new ArcGISHttpClient and setting this new instance on ArcGISEnvironment using ArcGISEnvironment.configureArcGISHttpClient.

The following example shows how to configure an interceptor that adds a custom header to every network request:

ArcGISEnvironment.configureArcGISHttpClient {
   interceptor { chain ->
      val request = chain.request()
      val modifiedRequest = request.newBuilder()
         .addHeader(customHeaderName, customHeaderValue)
         .build()
      chain.proceed(modifiedRequest)
   }
}

Since

200.2.0

See also

Functions

Link copied to clipboard
abstract fun intercept(chain: Chain): Response

Invoked when a network request is intercepted.