사용자 도구

사이트 도구


java:asynchttpclient

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! :-)
java/asynchttpclient.txt · 마지막으로 수정됨: 2022/05/18 14:30 저자 kwon37xi