mirror of
https://codeberg.org/icewind/logsmash.git
synced 2026-06-03 18:14:11 +02:00
fmt + clippy
This commit is contained in:
parent
ff3a0aa0e6
commit
73e00b699a
1 changed files with 5 additions and 8 deletions
|
|
@ -17,7 +17,7 @@ fn get_router(verb: &str) -> Option<&'static Router> {
|
||||||
.get_or_init(|| {
|
.get_or_init(|| {
|
||||||
let mut routers: HashMap<&'static str, Router> = HashMap::default();
|
let mut routers: HashMap<&'static str, Router> = HashMap::default();
|
||||||
for route in all_routes().filter(|route| !route.ocs) {
|
for route in all_routes().filter(|route| !route.ocs) {
|
||||||
let router = routers.entry(route.verb).or_insert_with(|| Router::new());
|
let router = routers.entry(route.verb).or_default();
|
||||||
let _ = router.insert(route.url, (route.id, route.url));
|
let _ = router.insert(route.url, (route.id, route.url));
|
||||||
}
|
}
|
||||||
routers
|
routers
|
||||||
|
|
@ -30,7 +30,7 @@ fn get_ocs_router(verb: &str) -> Option<&'static Router> {
|
||||||
.get_or_init(|| {
|
.get_or_init(|| {
|
||||||
let mut routers: HashMap<&'static str, Router> = HashMap::default();
|
let mut routers: HashMap<&'static str, Router> = HashMap::default();
|
||||||
for route in all_routes().filter(|route| route.ocs) {
|
for route in all_routes().filter(|route| route.ocs) {
|
||||||
let router = routers.entry(route.verb).or_insert_with(|| Router::new());
|
let router = routers.entry(route.verb).or_default();
|
||||||
let _ = router.insert(route.url, (route.id, route.url));
|
let _ = router.insert(route.url, (route.id, route.url));
|
||||||
}
|
}
|
||||||
routers
|
routers
|
||||||
|
|
@ -61,18 +61,15 @@ pub fn match_url<'a>(verb: &str, url: &'a str) -> Option<RouteMatch<'a>> {
|
||||||
|
|
||||||
let url = url.split_once('?').map(|(url, _)| url).unwrap_or(url);
|
let url = url.split_once('?').map(|(url, _)| url).unwrap_or(url);
|
||||||
let (router, url) = if let Some(ocs_url) = url.strip_prefix("/ocs/v2.php") {
|
let (router, url) = if let Some(ocs_url) = url.strip_prefix("/ocs/v2.php") {
|
||||||
(get_ocs_router(verb), ocs_url)
|
(get_ocs_router(verb)?, ocs_url)
|
||||||
} else if let Some(ocs_url) = url.strip_prefix("/ocs/v1.php") {
|
} else if let Some(ocs_url) = url.strip_prefix("/ocs/v1.php") {
|
||||||
(get_ocs_router(verb), ocs_url)
|
(get_ocs_router(verb)?, ocs_url)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
get_router(verb),
|
get_router(verb)?,
|
||||||
url.strip_prefix("/index.php").unwrap_or(url),
|
url.strip_prefix("/index.php").unwrap_or(url),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let Some(router) = router else {
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
router
|
router
|
||||||
.at(url)
|
.at(url)
|
||||||
.map(|m| RouteMatch::Route(m.value.0, m.value.1))
|
.map(|m| RouteMatch::Route(m.value.0, m.value.1))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue