Search in sources :

Example 1 with MyErrorDecoder

use of com.gpcoder.handler.MyErrorDecoder 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);
}
Also used : LoggingInterceptor(com.gpcoder.interceptor.LoggingInterceptor) OkHttpClient(feign.okhttp.OkHttpClient) GsonEncoder(feign.gson.GsonEncoder) MyErrorDecoder(com.gpcoder.handler.MyErrorDecoder) Slf4jLogger(feign.slf4j.Slf4jLogger) AuthInterceptor(com.gpcoder.interceptor.AuthInterceptor) GsonDecoder(feign.gson.GsonDecoder) FormEncoder(feign.form.FormEncoder)

Aggregations

MyErrorDecoder (com.gpcoder.handler.MyErrorDecoder)1 AuthInterceptor (com.gpcoder.interceptor.AuthInterceptor)1 LoggingInterceptor (com.gpcoder.interceptor.LoggingInterceptor)1 FormEncoder (feign.form.FormEncoder)1 GsonDecoder (feign.gson.GsonDecoder)1 GsonEncoder (feign.gson.GsonEncoder)1 OkHttpClient (feign.okhttp.OkHttpClient)1 Slf4jLogger (feign.slf4j.Slf4jLogger)1