File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1717
1818//! `cargo run --example fix_path --features response-macros`
1919
20+ use windmark:: router_option:: RouterOption ;
21+
2022#[ windmark:: main]
2123async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2224 windmark:: router:: Router :: new ( )
2325 . set_private_key_file ( "windmark_private.pem" )
2426 . set_certificate_file ( "windmark_public.pem" )
2527 . add_options ( & [
26- windmark:: router_option:: RouterOption :: RemoveExtraTrailingSlash ,
27- windmark:: router_option:: RouterOption :: AddMissingTrailingSlash ,
28+ RouterOption :: RemoveExtraTrailingSlash ,
29+ RouterOption :: AddMissingTrailingSlash ,
30+ RouterOption :: AllowCaseInsensitiveLookup ,
2831 ] )
2932 . mount (
3033 "/close" ,
Original file line number Diff line number Diff line change @@ -421,6 +421,14 @@ impl Router {
421421 }
422422
423423 let mut path = url. path ( ) . to_string ( ) ;
424+
425+ if self
426+ . options
427+ . contains ( & RouterOption :: AllowCaseInsensitiveLookup )
428+ {
429+ path = path. to_lowercase ( ) ;
430+ }
431+
424432 let mut route = self . routes . at ( & path) ;
425433
426434 if route. is_err ( ) {
Original file line number Diff line number Diff line change @@ -7,4 +7,7 @@ pub enum RouterOption {
77 /// If enabled, adds a trailing slash to the request URL path if a route
88 /// exists for the path with the slash (e.g., `/foo` becomes `/foo/`).
99 AddMissingTrailingSlash ,
10+ /// If enabled, the router will perform case-insensitive matching for
11+ /// incoming request URL paths (e.g., `/foo` will match `/Foo` or `/FOO`).
12+ AllowCaseInsensitiveLookup ,
1013}
You can’t perform that action at this time.
0 commit comments