Closed jdrouet closed 4 months ago
How would one simply add a before/after request ? Without copying all the current implementation.
You just need to implement crate::client::Executor
on a struct that would wrap the current default one.
Something like (I didn't test it)
struct MyExecutor {
inner: tmdb_api::client::reqwest::ReqwestExecutor,
}
#[async_trait::async_trait]
impl super::prelude::Executor for MyExecutor {
async fn execute<T: serde::de::DeserializeOwned>(
&self,
url: &str,
params: Vec<(&str, Cow<'_, str>)>,
) -> Result<T, crate::error::Error> {
// before
let result = self.inner.execute(url, params).await;
// after
result
}
}
In order to give the user the ability to have a feature reach client (like implementing a rate limiting system), we should allow them to implement their own. To do that, we should have a client trait that anybody could implement.