Skip to content

jkyeo/okhttp-basicparamsinterceptor

Repository files navigation

okhttp-basicparamsinterceptor

A Basic Params Interceptor for okhttp3.

Via this interceptor we can inject header, url-query and even body (post with "x-www-form-urlencoded" contentType) params into every http request in okhttp3.

Setup

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Step 2. Add the dependency

dependencies {
        compile 'com.github.jkyeo:okhttp-basicparamsinterceptor:v0.9'
}

Usage

BasicParamsInterceptor basicParamsInterceptor =
        new OkPublicParamsInterceptor.Builder()
                .addHeaderParam("device_id", DeviceUtils.getDeviceId())
                .addParam("uid", UserModel.getInstance().getUid())
                .addQueryParam("api_version", "1.1")
                .build();


OkHttpClient client = new OkHttpClient.Builder()
        .addInterceptor(basicParamsInterceptor)
        .build();

About

A Basic Params Interceptor for okhttp3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages