Skip to content

Commit

Permalink
fix: avoid complex blocks or closures with blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
bxf12315 authored and ctron committed Feb 13, 2024
1 parent 9e8b215 commit a8872ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/src/sender/provider/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ pub trait TokenInjector: Sized + Send + Sync {
impl TokenInjector for reqwest::RequestBuilder {
#[instrument(level = "debug", skip(token_provider), err)]
async fn inject_token(self, token_provider: &dyn TokenProvider) -> Result<Self, Error> {
if let Some(credentials) = token_provider.provide_access_token().await? {
Ok(match credentials {
let credentials_result = token_provider.provide_access_token().await?;
if let Some(credentials) = credentials_result {
let request_builder = match credentials {
Credentials::Bearer(token) => self.bearer_auth(token),
Credentials::Basic(username, password) => self.basic_auth(username, password),
})
};
Ok(request_builder)
} else {
Ok(self)
}
Expand Down

0 comments on commit a8872ff

Please sign in to comment.