From b701eb79faa22145ba5909c331b860986e6d4f32 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 23 Aug 2019 20:35:42 +0200 Subject: [PATCH 1/2] Redirect docs.rs/std to the official standard library docs. See also #56 and #193. --- src/web/mod.rs | 1 + src/web/rustdoc.rs | 6 ++++++ 2 files changed, 7 insertions(+) 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..bf148f6a3 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/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 { From 30a6d81ef198c3dbfebd3cdd151462e3213dbc32 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 11 Oct 2019 11:44:40 +0200 Subject: [PATCH 2/2] Update std doc url to specifically link to stable. --- src/web/rustdoc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/rustdoc.rs b/src/web/rustdoc.rs index bf148f6a3..bb75db8a9 100644 --- a/src/web/rustdoc.rs +++ b/src/web/rustdoc.rs @@ -68,7 +68,7 @@ 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/std/").unwrap(); + let url = Url::parse("https://doc.rust-lang.org/stable/std/").unwrap(); Ok(Response::with((status::Found, Redirect(url)))) }