aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-07-08 05:30:21 +0000
committerFuwn <[email protected]>2025-07-08 05:30:21 +0000
commit3e572d9f4092aad5dda01a7bc87c3c4377e289b1 (patch)
tree9523cccc017225cffdd599e930efb2e518eae285 /src
parentdocs(router_option): Expand documentation (diff)
downloadwindmark-3e572d9f4092aad5dda01a7bc87c3c4377e289b1.tar.xz
windmark-3e572d9f4092aad5dda01a7bc87c3c4377e289b1.zip
feat(router): Add case-insensitive route matching option
Diffstat (limited to 'src')
-rw-r--r--src/router.rs8
-rw-r--r--src/router_option.rs3
2 files changed, 11 insertions, 0 deletions
diff --git a/src/router.rs b/src/router.rs
index 6ae33b0..81eb6c4 100644
--- a/src/router.rs
+++ b/src/router.rs
@@ -421,6 +421,14 @@ impl Router {
}
let mut path = url.path().to_string();
+
+ if self
+ .options
+ .contains(&RouterOption::AllowCaseInsensitiveLookup)
+ {
+ path = path.to_lowercase();
+ }
+
let mut route = self.routes.at(&path);
if route.is_err() {
diff --git a/src/router_option.rs b/src/router_option.rs
index 62ecb47..a28ba6f 100644
--- a/src/router_option.rs
+++ b/src/router_option.rs
@@ -7,4 +7,7 @@ pub enum RouterOption {
/// If enabled, adds a trailing slash to the request URL path if a route
/// exists for the path with the slash (e.g., `/foo` becomes `/foo/`).
AddMissingTrailingSlash,
+ /// If enabled, the router will perform case-insensitive matching for
+ /// incoming request URL paths (e.g., `/foo` will match `/Foo` or `/FOO`).
+ AllowCaseInsensitiveLookup,
}