use of feign.gson.GsonDecoder in project carbon-apimgt by wso2.
the class DefaultScopeRegistrationImpl method getScope.
private Scope getScope(Response response) throws IOException {
Scope scope = new Scope();
ScopeInfo scopeInfoResponse = (ScopeInfo) new GsonDecoder().decode(response, ScopeInfo.class);
scope.setName(scopeInfoResponse.getName());
scope.setDescription(scopeInfoResponse.getDescription());
if (scopeInfoResponse.getBindings() != null) {
scope.setBindings(scopeInfoResponse.getBindings());
} else {
scope.setBindings(Collections.emptyList());
}
return scope;
}
use of feign.gson.GsonDecoder in project mesosFramework by zhizuqiu.
the class MesosClient method getInstance.
public static MesosIf getInstance(String url) {
GsonDecoder decoder = new GsonDecoder(GSON);
GsonEncoder encoder = new GsonEncoder(GSON);
return Feign.builder().encoder(encoder).decoder(decoder).errorDecoder(new MesosErrorDecoder()).requestInterceptor(new MesosHeadersInterceptor()).target(MesosIf.class, url);
}
use of feign.gson.GsonDecoder in project mesosFramework by zhizuqiu.
the class EtcdClient method getInstance.
public static Etcd getInstance(String url) {
GsonDecoder decoder = new GsonDecoder(GSON);
GsonEncoder encoder = new GsonEncoder(GSON);
return Feign.builder().encoder(encoder).decoder(decoder).errorDecoder(new EtcdErrorDecoder()).requestInterceptor(new EtcdHeadersInterceptor()).target(Etcd.class, url);
}
use of feign.gson.GsonDecoder in project feign by OpenFeign.
the class MockClientSequentialTest method setup.
@Before
public void setup() throws IOException {
try (InputStream input = getClass().getResourceAsStream("/fixtures/contributors.json")) {
byte[] data = toByteArray(input);
RequestHeaders headers = RequestHeaders.builder().add("Name", "netflix").build();
mockClientSequential = new MockClient(true);
githubSequential = Feign.builder().decoder(new AssertionDecoder(new GsonDecoder())).client(mockClientSequential.add(RequestKey.builder(HttpMethod.GET, "/repos/netflix/feign/contributors").headers(headers).build(), HttpsURLConnection.HTTP_OK, data).add(HttpMethod.GET, "/repos/netflix/feign/contributors?client_id=55", HttpsURLConnection.HTTP_NOT_FOUND).add(HttpMethod.GET, "/repos/netflix/feign/contributors?client_id=7 7", HttpsURLConnection.HTTP_INTERNAL_ERROR, new ByteArrayInputStream(data)).add(HttpMethod.GET, "/repos/netflix/feign/contributors", Response.builder().status(HttpsURLConnection.HTTP_OK).headers(RequestHeaders.EMPTY).body(data))).target(new MockTarget<>(GitHub.class));
}
}
use of feign.gson.GsonDecoder 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