Skip to main content

Module ant_matcher

Module ant_matcher 

Source
Expand description

Ant-style Path Matcher

Provides Spring-style Ant path matching for URL patterns. This is an alternative to regex-based matching, providing more intuitive pattern syntax commonly used in Spring Security.

§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

§Examples

use actix_security_core::http::security::ant_matcher::AntMatcher;

// Match any path under /api/
let matcher = AntMatcher::new("/api/**");
assert!(matcher.matches("/api/users"));
assert!(matcher.matches("/api/users/123/profile"));

// Match single segment wildcard
let matcher = AntMatcher::new("/users/*/profile");
assert!(matcher.matches("/users/123/profile"));
assert!(!matcher.matches("/users/123/456/profile"));

// Match single character
let matcher = AntMatcher::new("/file?.txt");
assert!(matcher.matches("/file1.txt"));
assert!(!matcher.matches("/file12.txt"));

§Spring Equivalent

org.springframework.util.AntPathMatcher

Structs§

AntMatcher
Ant-style path matcher
AntMatcherBuilder
Builder for creating multiple AntMatchers with common configuration
AntMatchers
Collection of AntMatchers for efficient path matching

Traits§

IntoAntMatcher
Extension trait for converting patterns to AntMatcher