Struct http_signatures::HttpSignature
[−]
[src]
pub struct HttpSignature<T> where
T: Read, { /* fields omitted */ }The HttpSignature struct, this is the entry point for creating an Authorization header. It
contains all the values required for generation.
Methods
impl<T> HttpSignature<T> where
T: Read, [src]
T: Read,
fn new(
key_id: String,
key: T,
algorithm: SignatureAlgorithm,
headers: HashMap<String, Vec<String>>
) -> Result<Self, CreationError>[src]
key_id: String,
key: T,
algorithm: SignatureAlgorithm,
headers: HashMap<String, Vec<String>>
) -> Result<Self, CreationError>
Create a new HttpSignature from its components.
This method will Error if headers is empty.
Example
use http_signatures::{HttpSignature, SignatureAlgorithm, ShaSize, REQUEST_TARGET}; let key_id = "test/assets/public.der".into(); let priv_key = File::open("test/assets/private.der")?; let alg = SignatureAlgorithm::RSA(ShaSize::FiveTwelve); let mut headers = HashMap::new(); headers.insert(REQUEST_TARGET.into(), vec!["get /".into()]); let http_sig = HttpSignature::new(key_id, priv_key, alg, headers)?;
fn key_id(&self) -> &str[src]
fn algorithm(&self) -> &SignatureAlgorithm[src]
fn headers(&self) -> &HashMap<String, Vec<String>>[src]
[src]
Generate the Authorization Header from the HttpSignature
This method errors if signing the signing-string fails.
Example
use http_signatures::HttpSignature; let auth_header = http_signature.authorization_header()?;
Trait Implementations
impl<T> AsHttpSignature<T> for HttpSignature<T> where
T: Read + Clone, [src]
T: Read + Clone,
A default implementation of AsHttpSignature for HttpSignature.
This only works if type T is Clone in addition to Read, which is normally required. This
implementation doesn't serve much of a purpose.
fn as_http_signature(
&self,
_: String,
_: T,
_: SignatureAlgorithm
) -> Result<Self, Error>[src]
&self,
_: String,
_: T,
_: SignatureAlgorithm
) -> Result<Self, Error>
Gets an HttpSignature struct from an immutably borrowed Self
[src]
Generates the Authorization Header from an immutably borrowed Self