use of com.gpcoder.interceptor.AuthInterceptor in project Java-Tutorial by gpcodervn.
the class OkHttpClientWithInterceptorExample method main.
public static void main(String[] args) throws IOException {
client = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor()).addInterceptor(new AuthInterceptor()).addNetworkInterceptor(new LoggingInterceptor()).build();
createOrder();
retrieveOrder();
updateOrder();
deleteOrder();
}
use of com.gpcoder.interceptor.AuthInterceptor in project Java-Tutorial by gpcodervn.
the class FeignClientCreator method getService.
public static <T> T getService(Class<T> clazz) {
okhttp3.OkHttpClient okHttpClient = new okhttp3.OkHttpClient.Builder().addInterceptor(new LoggingInterceptor()).addInterceptor(new AuthInterceptor()).addNetworkInterceptor(new LoggingInterceptor()).build();
OkHttpClient feignOkHttp = new OkHttpClient(okHttpClient);
return Feign.builder().client(feignOkHttp).encoder(new FormEncoder(new GsonEncoder())).decoder(new GsonDecoder()).logger(new Slf4jLogger(clazz)).errorDecoder(new MyErrorDecoder()).logLevel(Logger.Level.FULL).target(clazz, BASE_URL);
}
Aggregations