문서의 선택한 두 판 사이의 차이를 보여줍니다.
다음 판 | 이전 판 | ||
java:asynchttpclient [2022/05/18 14:24] kwon37xi 만듦 |
java:asynchttpclient [2022/05/18 14:30] (현재) kwon37xi |
||
---|---|---|---|
줄 3: | 줄 3: | ||
* async, non-blocking IO Java HTTP Client | * async, non-blocking IO Java HTTP Client | ||
+ | ===== Retrofit 2 지원 ===== | ||
+ | * https:// | ||
+ | * [[java: | ||
+ | * '' | ||
+ | <code java> | ||
+ | // instantiate async-http-client | ||
+ | AsyncHttpClient httpClient = ... | ||
+ | |||
+ | // instantiate async-http-client call factory | ||
+ | Call.Factory callFactory = AsyncHttpClientCallFactory.builder() | ||
+ | .httpClient(httpClient) | ||
+ | .onRequestStart(onRequestStart) | ||
+ | .onRequestFailure(onRequestFailure) | ||
+ | .onRequestSuccess(onRequestSuccess) | ||
+ | .requestCustomizer(requestCustomizer) | ||
+ | .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(" | ||
+ | |||
+ | // time to instantiate service | ||
+ | GitHub github = retrofit.create(Github.class); | ||
+ | |||
+ | // enjoy your type-safe github service api! :-) | ||
+ | </ |