Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
allow for Authorization header override with raw parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian1108 committed May 25, 2023
1 parent 748fd27 commit c85ee28
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ethers-providers/src/rpc/transports/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ pub enum Authorization {
Basic(String),
/// Bearer Auth
Bearer(String),
/// If you need to override the Authorization header value
Raw(String)
}

impl Authorization {
Expand All @@ -251,13 +253,19 @@ impl Authorization {
pub fn bearer(token: impl Into<String>) -> Self {
Self::Bearer(token.into())
}

/// Override the Authorization header with your own string
pub fn raw(token: impl Into<String>) -> Self {
Self::Raw(token.into())
}
}

impl fmt::Display for Authorization {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Authorization::Basic(auth_secret) => write!(f, "Basic {auth_secret}"),
Authorization::Bearer(token) => write!(f, "Bearer {token}"),
Authorization::Raw(s) => write!(f, "{s}")
}
}
}
Expand Down

0 comments on commit c85ee28

Please sign in to comment.