Open patrykcelinski opened 4 years ago
https://github.com/SuperXtra/githubApi/blob/9f55aed6b5491cfd8849cc0dfd6a36333d144756/app/com/scalac/service/CallExternalApi.scala#L20
Use pureconfig.
Create
case class GithubApiConfig( ghToken: String, baseUrl: String )
In application.conf
{ gh-token: "e0b8a7575abb45507853143c6e9f9f8743141a26" base-url: "https://api.github.com" }
Then in GithubApiModule you can have:
GithubApiModule
val githubApiConfig = ConfigSource.defaultApplication.loadOrThrow[GithubApiConfig] bind(classOf[GithubApiConfig]).toInstance(githubApiConfig)
and inject it to service:
class GetOrganisationContributors @Inject()(ws: WSClient, githubApiConfig: GithubApiConfig) {
Forgot that you need these imports in GithubApiModule or you will swear at pureconfig and me.
import pureconfig._ import pureconfig.generic.auto._
https://github.com/SuperXtra/githubApi/blob/9f55aed6b5491cfd8849cc0dfd6a36333d144756/app/com/scalac/service/CallExternalApi.scala#L20
Use pureconfig.
Create
In application.conf
Then in
GithubApiModule
you can have:and inject it to service: