Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the customizable HttpClient configuration #28

Merged
merged 1 commit into from
Mar 5, 2023

Conversation

ChrisKruegerDev
Copy link
Owner

@ChrisKruegerDev ChrisKruegerDev commented Mar 4, 2023

Related to #25

Idea:

        val tmdb = Tmdb3 {
            tmdbApiKey = "key"
            tmdbAuthenticationToken = "token"

            tmdbAccountCredentials {
                val storage = TmdbAccountStorage() // use own class here
                sessionId { storage.sessionId  }
                requestToken { storage.requestToken }
                accessToken { storage.accessToken }
            }

            httpClient(OkHttp) {
               engine {
                    // for own client
               }
            }

            httpClient {
                // for custom config
            }
        }

val showEpisodes by buildApi(::TmdbShowEpisodesApi)
val showEpisodeGroups by buildApi(::TmdbShowEpisodeGroupsApi)

private fun <T> buildApi(builder: (HttpClient) -> T) = lazy { builder(client) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for making these lazy. You can probably make this function inline

}

if (config.useCache) {
// TODO: Set persistent cache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is tricky because you need a File

@ChrisKruegerDev ChrisKruegerDev changed the title Setup TMDB client config Improve the customizable HttpClient configuration Mar 5, 2023
@ChrisKruegerDev ChrisKruegerDev merged commit ae8131a into main Mar 5, 2023
@ChrisKruegerDev ChrisKruegerDev deleted the ck/configuration branch March 5, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants