aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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,
}