Skip to content

Instantly share code, notes, and snippets.

@ininmm
Created October 12, 2019 12:50
Show Gist options
  • Save ininmm/82a1d3102a297ec01da4f72c9bccca7d to your computer and use it in GitHub Desktop.
Save ininmm/82a1d3102a297ec01da4f72c9bccca7d to your computer and use it in GitHub Desktop.
Write a sample api
interface SearchService {
@GET("search/repositories")
suspend fun searchRepo(
@Query("q", encoded = true) repo: String = "coil+org:coil-kt"
): SearchRepo
}
@Module
class NetworkModule {
@Singleton
@Provides
fun provideGithubService(): SearchService {
return Retrofit.Builder()
.baseUrl("https://api.github.com")
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(SearchService::class.java)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment