Explain Retrofit Interceptors and write a static API key interceptor
Tests OkHttp interception and application versus network scope. Strong answers build a new request adding X-Api-Key via newBuilder and chain.proceed; contrast addInterceptor once versus addNetworkInterceptor per hop.
This tests your understanding of OkHttp's interceptor chain and the application versus network interceptor boundary. A strong answer defines interceptors as mechanisms to monitor, rewrite, and retry calls; writes an Interceptor that builds a new Request via chain.request().newBuilder().addHeader("X-Api-Key", "your_key") and returns chain.proceed(newRequest); and explains that addInterceptor runs once while addNetworkInterceptor runs on every network hop including redirects.
Read the original → square.github.io
- #android
- #kotlin
- #okhttp
- #retrofit
- #interceptor
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.