From 3f8a7a0787f1bab61eeed06d47da5e6bd7b4aa40 Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Thu, 1 Oct 2015 11:15:49 -0700 Subject: [PATCH] godoc/redirect: add redirect for design proposals at /design/. Change-Id: Ifa10c0477a7d79673f7f841b5aebb448742cc378 Reviewed-on: https://go-review.googlesource.com/15280 Reviewed-by: Brad Fitzpatrick --- godoc/redirect/redirect.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/godoc/redirect/redirect.go b/godoc/redirect/redirect.go index 77d927d1..ed9af933 100644 --- a/godoc/redirect/redirect.go +++ b/godoc/redirect/redirect.go @@ -36,6 +36,7 @@ func Register(mux *http.ServeMux) { mux.HandleFunc("/src/pkg/", srcPkgHandler) mux.HandleFunc("/cl/", clHandler) mux.HandleFunc("/change/", changeHandler) + mux.HandleFunc("/design/", designHandler) } func handlePathRedirects(mux *http.ServeMux, redirects map[string]string, prefix string) { @@ -230,3 +231,15 @@ func changeHandler(w http.ResponseWriter, r *http.Request) { } http.Redirect(w, r, target, http.StatusFound) } + +func designHandler(w http.ResponseWriter, r *http.Request) { + const prefix = "/design/" + if p := r.URL.Path; p == prefix { + // redirect /prefix/ to /prefix + http.Redirect(w, r, p[:len(p)-1], http.StatusFound) + return + } + name := r.URL.Path[len(prefix):] + target := "https://github.com/golang/proposal/blob/master/design/" + name + ".md" + http.Redirect(w, r, target, http.StatusFound) +}