pub struct BasicAuthLayer { /* private fields */ }Expand description
Middleware layer that adds HTTP Basic authentication headers to requests.
This layer automatically adds the Authorization header with Basic authentication
credentials to all outgoing requests.
§Examples
use kintone::middleware::BasicAuthLayer;
// Enable Basic authentication
let basic_auth = BasicAuthLayer::new(Some(("username".to_string(), "password".to_string())));
// Disable Basic authentication
let no_auth = BasicAuthLayer::new(None);Combined with other middleware:
use std::time::Duration;
use kintone::client::{Auth, KintoneClientBuilder};
use kintone::middleware;
let client = KintoneClientBuilder::new(
"https://your-domain.cybozu.com",
Auth::api_token("your-api-token".to_owned())
)
.layer(middleware::BasicAuthLayer::new(Some(("basicauth_user".to_string(), "basicauth_password".to_string()))))
.layer(middleware::RetryLayer::new()
.with_max_attempts(5)
.with_initial_delay(Duration::from_secs(1))
.with_max_delay(Duration::from_secs(8))
)
.layer(middleware::LoggingLayer::new())
.build();Implementations§
Source§impl BasicAuthLayer
impl BasicAuthLayer
Sourcepub fn new(credentials: Option<(String, String)>) -> Self
pub fn new(credentials: Option<(String, String)>) -> Self
Creates a new Basic authentication layer with optional credentials.
§Arguments
credentials- Optional tuple of (username, password) for Basic authentication. PassNoneto disable Basic authentication, orSome((username, password))to enable it.
§Examples
use kintone::middleware::BasicAuthLayer;
// Enable Basic authentication
let basic_auth = BasicAuthLayer::new(Some(("myuser".to_string(), "mypassword".to_string())));
// Disable Basic authentication
let no_auth = BasicAuthLayer::new(None);Sourcepub fn enabled(username: impl Into<String>, password: impl Into<String>) -> Self
pub fn enabled(username: impl Into<String>, password: impl Into<String>) -> Self
Creates a new Basic authentication layer with the provided credentials.
This is a convenience method that automatically wraps the credentials in Some().
§Arguments
username- The username for Basic authenticationpassword- The password for Basic authentication
§Examples
use kintone::middleware::BasicAuthLayer;
let basic_auth = BasicAuthLayer::enabled("myuser", "mypassword");Trait Implementations§
Auto Trait Implementations§
impl Freeze for BasicAuthLayer
impl RefUnwindSafe for BasicAuthLayer
impl Send for BasicAuthLayer
impl Sync for BasicAuthLayer
impl Unpin for BasicAuthLayer
impl UnsafeUnpin for BasicAuthLayer
impl UnwindSafe for BasicAuthLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more