diff --git a/src/web/mod.rs b/src/web/mod.rs index 841c98e95..86efb510a 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -101,6 +101,7 @@ impl CratesfyiHandler { router.get("/robots.txt", sitemap::robots_txt_handler, "robots_txt"); router.get("/sitemap.xml", sitemap::sitemap_handler, "sitemap_xml"); router.get("/opensearch.xml", opensearch_xml_handler, "opensearch_xml"); + router.get("/std", rustdoc::std_redirector_handler, "std"); router.get("/releases", releases::recent_releases_handler, "releases"); router.get("/releases/feed", releases::releases_feed_handler, diff --git a/src/web/rustdoc.rs b/src/web/rustdoc.rs index a7fe8f8c0..bb75db8a9 100644 --- a/src/web/rustdoc.rs +++ b/src/web/rustdoc.rs @@ -66,6 +66,12 @@ impl ToJson for RustdocPage { } +/// Handler called for the `/std`. Redirects to the official standard library docs. +pub fn std_redirector_handler(_req: &mut Request) -> IronResult { + let url = Url::parse("https://doc.rust-lang.org/stable/std/").unwrap(); + Ok(Response::with((status::Found, Redirect(url)))) +} + /// Handler called for `/:crate` and `/:crate/:version` URLs. Automatically redirects to the docs /// or crate details page based on whether the given crate version was successfully built. pub fn rustdoc_redirector_handler(req: &mut Request) -> IronResult {