반응형
//네이버 api
var retrofitNaverPart = module{
httpLoggingInterceptor.apply {
httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
}
single<PapagoService>{
Retrofit.Builder()
.baseUrl("https://openapi.naver.com/")
.client(get<OkHttpClient>((named("retrofitNaverPart"))))
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(PapagoService::class.java)
}
single<OkHttpClient>(named("retrofitNaverPart")) {
OkHttpClient.Builder()
.connectTimeout(120, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(120, TimeUnit.SECONDS)
.addInterceptor(httpLoggingInterceptor)
.addInterceptor { chain ->
val originalRequest = chain.request()
val builder = originalRequest.newBuilder()
.header("X-Naver-Client-Id","blah")
.header("X-Naver-Client-Secret","blah")
val newRequest = builder.build()
chain.proceed(newRequest)
}
.build()
}
}
.client(get<OkHttpClient>((named("retrofitNaverPart"))))
Retrofit single 부분에 .client로 okHttpClient 추가해주어야한다,,,,^^;
'IT > Android' 카테고리의 다른 글
안드로이드 스튜디오 / 'constructor Handler()' is deprecated. Deprecated in Java (0) | 2022.03.08 |
---|---|
안드로이드 스튜디오 / View Binding 초기 설정 (0) | 2022.03.08 |
ACC의 ViewModel (!=MVVM의 ViewModel) (0) | 2022.02.22 |
Socket 네트워크 (0) | 2022.01.25 |
안드로이드 스튜디오 / Fragment에서 ViewBinding (뷰결합) (0) | 2022.01.12 |