Struct reqsign::AzureStorageSigner
source · pub struct AzureStorageSigner { /* private fields */ }
Expand description
Singer that implement Azure Storage Shared Key Authorization.
Implementations§
source§impl Signer
impl Signer
sourcepub fn sign(
&self,
req: &mut impl SignableRequest,
cred: &Credential
) -> Result<()>
pub fn sign( &self, req: &mut impl SignableRequest, cred: &Credential ) -> Result<()>
Signing request.
Example
use anyhow::Result;
use reqsign::AzureStorageSigner;
use reqwest::Client;
use reqwest::Request;
use reqwest::Url;
#[tokio::main]
async fn main() -> Result<()> {
// Signer will load region and credentials from environment by default.
let signer = AzureStorageSigner::builder()
.account_name("account_name")
.account_key("YWNjb3VudF9rZXkK")
.build()?;
// Construct request
let url = Url::parse("https://test.blob.core.windows.net/testbucket/testblob")?;
let mut req = reqwest::Request::new(http::Method::GET, url);
// Signing request with Signer
signer.sign(&mut req)?;
// Sending already signed request.
let resp = Client::new().execute(req).await?;
println!("resp got status: {}", resp.status());
Ok(())
}
sourcepub fn sign_query(
&self,
req: &mut impl SignableRequest,
expire: Duration,
cred: &Credential
) -> Result<()>
pub fn sign_query( &self, req: &mut impl SignableRequest, expire: Duration, cred: &Credential ) -> Result<()>
Signing request with query.