pub struct AntMatcher { /* private fields */ }Expand description
Ant-style path matcher
Provides pattern matching similar to Spring’s AntPathMatcher.
Implementations§
Source§impl AntMatcher
impl AntMatcher
Sourcepub fn new(pattern: &str) -> AntMatcher
pub fn new(pattern: &str) -> AntMatcher
Create a new AntMatcher with the given pattern
§Pattern Syntax
?matches exactly one character*matches zero or more characters within a path segment**matches zero or more path segments{name}captures a named path variable
§Example
use actix_security_core::http::security::ant_matcher::AntMatcher;
let matcher = AntMatcher::new("/api/**");
assert!(matcher.matches("/api/users"));Sourcepub fn case_insensitive(self) -> AntMatcher
pub fn case_insensitive(self) -> AntMatcher
Create a case-insensitive matcher
Sourcepub fn matches(&self, path: &str) -> bool
pub fn matches(&self, path: &str) -> bool
Check if the given path matches this pattern
§Example
use actix_security_core::http::security::ant_matcher::AntMatcher;
let matcher = AntMatcher::new("/users/*/profile");
assert!(matcher.matches("/users/123/profile"));
assert!(!matcher.matches("/users/profile"));Sourcepub fn extract_variables(&self, path: &str) -> Option<HashMap<String, String>>
pub fn extract_variables(&self, path: &str) -> Option<HashMap<String, String>>
Check if the path matches and extract path variables
§Example
use actix_security_core::http::security::ant_matcher::AntMatcher;
let matcher = AntMatcher::new("/users/{id}/posts/{postId}");
let vars = matcher.extract_variables("/users/123/posts/456");
assert!(vars.is_some());
let vars = vars.unwrap();
assert_eq!(vars.get("id"), Some(&"123".to_string()));
assert_eq!(vars.get("postId"), Some(&"456".to_string()));Trait Implementations§
Source§impl Clone for AntMatcher
impl Clone for AntMatcher
Source§fn clone(&self) -> AntMatcher
fn clone(&self) -> AntMatcher
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AntMatcher
impl Debug for AntMatcher
Source§impl IntoAntMatcher for AntMatcher
impl IntoAntMatcher for AntMatcher
fn into_ant_matcher(self) -> AntMatcher
Auto Trait Implementations§
impl Freeze for AntMatcher
impl RefUnwindSafe for AntMatcher
impl Send for AntMatcher
impl Sync for AntMatcher
impl Unpin for AntMatcher
impl UnwindSafe for AntMatcher
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more