Skip to content

Commit

Permalink
refactor: BaseUrlQualifier 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyCh0 committed Sep 20, 2023
1 parent c466dd7 commit 4b0fb36
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ annotation class NormalRetrofitQualifier
@Retention(AnnotationRetention.BINARY)
annotation class AuthRetrofitQualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class BaseUrlQualifier

@InstallIn(SingletonComponent::class)
@Module
object ApiModule {
Expand All @@ -37,22 +41,25 @@ object ApiModule {
@Provides
@Singleton
@NormalRetrofitQualifier
fun providesNormalRetrofit(baseUrl: String): Retrofit = Retrofit.Builder()
fun providesNormalRetrofit(@BaseUrlQualifier baseUrl: String): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()

@Provides
@Singleton
@AuthRetrofitQualifier
fun providesAuthRetrofit(baseUrl: String, okHttpClient: OkHttpClient): Retrofit =
Retrofit.Builder()
.baseUrl(baseUrl)
.client(okHttpClient)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()
fun providesAuthRetrofit(
@BaseUrlQualifier baseUrl: String,
okHttpClient: OkHttpClient
): Retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.client(okHttpClient)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()

@Provides
@Singleton
@BaseUrlQualifier
fun providesBaseUrl(): String = BuildConfig.BASE_URL
}

0 comments on commit 4b0fb36

Please sign in to comment.