Skip to content

Commit 6bb4ab3

Browse files
committed
Handle redirects more uniformly
1 parent 5ab5127 commit 6bb4ab3

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/main.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async fn team(
223223
section: &str,
224224
team: &str,
225225
teams_cache: &Cache<RustTeams>,
226-
) -> Result<Template, Result<Redirect, Status>> {
226+
) -> Result<Template, Status> {
227227
render_team(section, team, ENGLISH.into(), teams_cache).await
228228
}
229229

@@ -241,7 +241,7 @@ async fn team_locale(
241241
team: &str,
242242
locale: SupportedLocale,
243243
teams_cache: &Cache<RustTeams>,
244-
) -> Result<Template, Result<Redirect, Status>> {
244+
) -> Result<Template, Status> {
245245
render_team(section, team, locale.0, teams_cache).await
246246
}
247247

@@ -440,7 +440,7 @@ async fn render_team(
440440
team: &str,
441441
lang: String,
442442
teams_cache: &Cache<RustTeams>,
443-
) -> Result<Template, Result<Redirect, Status>> {
443+
) -> Result<Template, Status> {
444444
match teams::page_data(section, team, teams_cache).await {
445445
Ok(data) => {
446446
let page = "governance/group";
@@ -450,16 +450,10 @@ async fn render_team(
450450
}
451451
Err(err) => {
452452
if err.is::<teams::TeamNotFound>() {
453-
match (section, team) {
454-
// Old teams URLs
455-
("teams", "language-and-compiler") | ("teams", "operations") => {
456-
Err(Ok(Redirect::temporary("/governance")))
457-
}
458-
_ => Err(Err(Status::NotFound)),
459-
}
453+
Err(Status::NotFound)
460454
} else {
461455
eprintln!("error while loading the team page: {}", err);
462-
Err(Err(Status::InternalServerError))
456+
Err(Status::InternalServerError)
463457
}
464458
}
465459
}

src/redirect.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static PAGE_REDIRECTS: &[(&str, &str)] = &[
3333
"governance/teams/crates-io",
3434
"governance/teams/dev-tools#team-crates-io",
3535
),
36+
("governance/teams/language-and-compiler", "governance#teams"),
37+
("governance/teams/operations", "governance#teams"),
3638
// miscellaneous
3739
("governance/teams", "governance#teams"),
3840
];

0 commit comments

Comments
 (0)