Expand description
§Radix Trie for URL Routing
A space-efficient trie that compresses paths by storing common prefixes in single nodes. This prevents DoS attacks from extremely long segmented paths while maintaining fast lookups.
This crate supports:
- Wildcard Support: Routes ending in
/*match any sub-path - Fast Lookups:
O(path_length)`` instead ofO(number_of_routes)` - DoS Resistant: Long paths don’t create excessive nodes
- Compressed representation:
/api/v1/usersand/api/v1/postsshare the/api/v1/prefix
§Example
use wildcard_trie::Trie;
let mut trie = Trie::new();
trie.insert("/api/*", "api_handler"); // Wildcard
trie.insert("/api/users", "users_handler"); // Exact (takes precedence)
assert_eq!(trie.get("/api/users"), Some(&"users_handler")); // Exact match
assert_eq!(trie.get("/api/posts"), Some(&"api_handler")); // Wildcard matchStructs§
- Trie
- A radix trie for efficient path-based routing with wildcard support