AsyncHttpClient

Retrofit 2 지원

// instantiate async-http-client
AsyncHttpClient httpClient = ...
 
// instantiate async-http-client call factory
Call.Factory callFactory = AsyncHttpClientCallFactory.builder()
    .httpClient(httpClient)                 // required
    .onRequestStart(onRequestStart)         // optional
    .onRequestFailure(onRequestFailure)     // optional
    .onRequestSuccess(onRequestSuccess)     // optional
    .requestCustomizer(requestCustomizer)   // optional
    .build();
 
// instantiate retrofit
Retrofit retrofit = new Retrofit.Builder()
    .callFactory(callFactory) // use our own call factory
    .addConverterFactory(ScalarsConverterFactory.create())
    .addConverterFactory(JacksonConverterFactory.create())
    // ... add other converter factories
    // .addCallAdapterFactory(RxJavaCallAdapterFactory.createAsync())
    .validateEagerly(true) // highly recommended!!!
    .baseUrl("https://api.github.com/");
 
// time to instantiate service
GitHub github = retrofit.create(Github.class);
 
// enjoy your type-safe github service api! :-)