Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle redirects more uniformly #1980

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ async fn team(
section: &str,
team: &str,
teams_cache: &Cache<RustTeams>,
) -> Result<Template, Result<Redirect, Status>> {
) -> Result<Template, Status> {
render_team(section, team, ENGLISH.into(), teams_cache).await
}

Expand All @@ -241,7 +241,7 @@ async fn team_locale(
team: &str,
locale: SupportedLocale,
teams_cache: &Cache<RustTeams>,
) -> Result<Template, Result<Redirect, Status>> {
) -> Result<Template, Status> {
render_team(section, team, locale.0, teams_cache).await
}

Expand Down Expand Up @@ -440,7 +440,7 @@ async fn render_team(
team: &str,
lang: String,
teams_cache: &Cache<RustTeams>,
) -> Result<Template, Result<Redirect, Status>> {
) -> Result<Template, Status> {
match teams::page_data(section, team, teams_cache).await {
Ok(data) => {
let page = "governance/group";
Expand All @@ -450,16 +450,10 @@ async fn render_team(
}
Err(err) => {
if err.is::<teams::TeamNotFound>() {
match (section, team) {
// Old teams URLs
("teams", "language-and-compiler") | ("teams", "operations") => {
Err(Ok(Redirect::temporary("/governance")))
}
_ => Err(Err(Status::NotFound)),
}
Err(Status::NotFound)
} else {
eprintln!("error while loading the team page: {}", err);
Err(Err(Status::InternalServerError))
Err(Status::InternalServerError)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ static PAGE_REDIRECTS: &[(&str, &str)] = &[
"governance/teams/crates-io",
"governance/teams/dev-tools#team-crates-io",
),
("governance/teams/language-and-compiler", "governance#teams"),
("governance/teams/operations", "governance#teams"),
// miscellaneous
("governance/teams", "governance#teams"),
];
Expand Down
Loading