mirror of
https://github.com/golang/go
synced 2024-11-18 15:34:53 -07:00
godoc/redirect: add redirect for design proposals at /design/.
Change-Id: Ifa10c0477a7d79673f7f841b5aebb448742cc378 Reviewed-on: https://go-review.googlesource.com/15280 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
e1d85eb8a3
commit
3f8a7a0787
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user