Struct http_srv::request::handler::AuthConfig
source · pub struct AuthConfig { /* private fields */ }Expand description
Authentication Config
Helps wrapping handler functions behing authentication
§Example
use http_srv::request::handler::AuthConfig;
use http_srv::request::handler::Handler;
use http_srv::HttpRequest;
let auth = AuthConfig::of_list(&[("user", "passwd")]);
let mut handler = Handler::default();
let func = |req: &mut HttpRequest| {
req.respond_str("Super secret message")
};
handler.get("/secret", auth.apply(func));Implementations§
source§impl AuthConfig
impl AuthConfig
pub fn of_file(filename: &str) -> Self
pub fn of_list(list: &[(&str, &str)]) -> Self
pub fn require_user(self, user: &str) -> Self
pub fn apply(&self, f: impl HandlerFunc) -> impl HandlerFunc
Trait Implementations§
source§impl<F> Add<F> for &AuthConfigwhere
F: HandlerFunc,
impl<F> Add<F> for &AuthConfigwhere
F: HandlerFunc,
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnwindSafe for AuthConfig
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