use reqwest::header::{HeaderName, HeaderValue};
#[derive(Debug)]
pub struct AuthApiKey {
pub api_key: String,
}
impl AuthApiKey {
pub fn new(api_key: &str) -> Self {
AuthApiKey {
api_key: api_key.into(),
}
}
pub fn get_header_value(&self) -> HeaderValue {
let mut bearer = String::from("Bearer ");
bearer.push_str(&self.api_key);
let header_val = HeaderValue::from_str(&bearer).unwrap();
return header_val;
}
}
#[derive(Debug)]
pub struct ApiKey {
pub api_header: String,
pub api_key: String,
}
impl ApiKey {
pub fn new(api_header: &str, api_key: &str) -> Self {
ApiKey {
api_header: api_header.into(),
api_key: api_key.into(),
}
}
pub fn get_header_name(&self) -> HeaderName {
let header_name = HeaderName::from_bytes(self.api_header.as_bytes()).unwrap();
return header_name;
}
pub fn get_header_value(&self) -> HeaderValue {
let header_val = HeaderValue::from_str(&self.api_key).unwrap();
return header_val;
}
}