mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 02:16:30 +00:00
trim path trailing slashes before route match (#99)
This commit is contained in:
parent
7ebffe019f
commit
461dfe2fbd
1 changed files with 4 additions and 1 deletions
|
@ -85,7 +85,10 @@ impl App {
|
|||
let logger2 = logger.clone();
|
||||
let start = Instant::now();
|
||||
|
||||
let res = if let Ok(route_match) = self.router.recognize(req.uri().path()) {
|
||||
// allows `/path/` to also match `/path`
|
||||
let normalized_path = req.uri().path().trim_end_matches('/');
|
||||
|
||||
let res = if let Ok(route_match) = self.router.recognize(normalized_path) {
|
||||
match (req.method(), route_match.handler()) {
|
||||
(&Method::GET, Route::Index) => {
|
||||
self.index(req, route_match.params().clone(), logger).await
|
||||
|
|
Loading…
Reference in a new issue