match_path

Function match_path 

Source
pub fn match_path(path: &str, pattern: &str) -> bool
Expand description

Match a path against a pattern (Ant-style wildcard) 匹配路径与模式(Ant 风格通配符)

§Arguments

  • path: The request path to match
  • pattern: The pattern to match against

§Patterns Supported

  • /**: Match all paths
  • /api/**: Match all paths starting with /api/
  • /api/*: Match single-level paths under /api/
  • *.html: Match paths ending with .html
  • /exact: Exact match

§Examples

use sa_token_core::router::match_path;
assert!(match_path("/api/user", "/api/**"));
assert!(match_path("/api/user", "/api/*"));
assert!(!match_path("/api/user/profile", "/api/*"));