Skip to content

Commit 4419dc8

Browse files
authored
Merge pull request #398 from fusion-engineering-forks/std-redirect
Redirect docs.rs/std to the official standard library docs.
2 parents 8b0b126 + 30a6d81 commit 4419dc8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/web/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ impl CratesfyiHandler {
103103
router.get("/robots.txt", sitemap::robots_txt_handler, "robots_txt");
104104
router.get("/sitemap.xml", sitemap::sitemap_handler, "sitemap_xml");
105105
router.get("/opensearch.xml", opensearch_xml_handler, "opensearch_xml");
106+
router.get("/std", rustdoc::std_redirector_handler, "std");
106107
router.get("/releases", releases::recent_releases_handler, "releases");
107108
router.get("/releases/feed",
108109
releases::releases_feed_handler,

src/web/rustdoc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ impl ToJson for RustdocPage {
6666
}
6767

6868

69+
/// Handler called for the `/std`. Redirects to the official standard library docs.
70+
pub fn std_redirector_handler(_req: &mut Request) -> IronResult<Response> {
71+
let url = Url::parse("https://doc.rust-lang.org/stable/std/").unwrap();
72+
Ok(Response::with((status::Found, Redirect(url))))
73+
}
74+
6975
/// Handler called for `/:crate` and `/:crate/:version` URLs. Automatically redirects to the docs
7076
/// or crate details page based on whether the given crate version was successfully built.
7177
pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult<Response> {

0 commit comments

Comments
 (0)