jdrouet / tmdb-api

Yet another TMDB api client written in rust, working with async
13 stars 8 forks source link

Ability to provide the Reqwest client #35

Closed fusetim closed 1 year ago

fusetim commented 1 year ago

As explained in the Reqwest::Client documentation, it's always preferable to be able to create a client and reuse it. In theory, since my application already uses a Reqwest::Client, I should be able to reuse it with tmdb_api.

There won't have issue with ownership, since Reqwest::Client already embeds an Arc, so cloning the client allows it to be reused without worry.

I'm planning to propose a PR to add the with_http_client(api_key: String, client: reqwest::Client) constructor to tmdb_api::client::Client, along the lines of the Vec::with_capacity constructor. Let me know if this works for you?