Skip to content

Instantly share code, notes, and snippets.

@dinorahto
Created May 1, 2019 18:15
Show Gist options
  • Save dinorahto/285b0b5d523bd908ac33a685ee12b4dc to your computer and use it in GitHub Desktop.
Save dinorahto/285b0b5d523bd908ac33a685ee12b4dc to your computer and use it in GitHub Desktop.
Extending Interceptor for HTTP request
/**
* Created by Dinorah Tovar on 04/04/18.
* Secondary helper interceptor to skip interceptor headers over Data Module
*/
class SupportInterceptor: Interceptor {
/**
* Interceptor class for setting of the headers for every request
*/
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()
request = request?.newBuilder()
?.addHeader("Content-Type", "application/json")
?.addHeader("Accept", "application/json")
?.build()
return chain.proceed(request)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment