fix: allow custom status codes or redirects for route fallbacks (#3808)

This commit is contained in:
Greg Johnston
2025-04-01 19:25:59 -04:00
committed by GitHub
parent 7d3a9da577
commit 47aebf3e22

View File

@@ -2061,7 +2061,15 @@ where
},
)
.await;
*res.status_mut() = StatusCode::NOT_FOUND;
// set the status to 404
// but if the status was already set (for example, to a 302 redirect) don't
// overwrite it
let status = res.status_mut();
if *status == StatusCode::OK {
*res.status_mut() = StatusCode::NOT_FOUND;
}
res
}
}