Struct reqsign::HuaweicloudObsSigner
source · pub struct HuaweicloudObsSigner { /* private fields */ }
Expand description
Singer that implement Huawei Cloud Object Storage Service 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::HuaweicloudObsSigner;
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 = HuaweicloudObsSigner::builder()
.access_key("access_key")
.secret_key("123456")
.bucket("bucket")
.build()?;
// Construct request
let url = Url::parse("https://bucket.obs.cn-north-4.myhuaweicloud.com/object.txt")?;
let mut req = 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.