From 5f7f96b50bf797cac2fb40262c7b69f8ad7025f9 Mon Sep 17 00:00:00 2001 From: Ian Lewis Date: Wed, 3 Apr 2019 01:48:18 -0400 Subject: Add a /syscall redirect to compatibility docs /syscall -> /docs/user_guide/compatibility/amd64 /syscall/amd64 -> /docs/user_guide/compatibility/amd64 /syscall/amd64/.* -> /docs/user_guide/compatibility/amd64/#%s --- cmd/gvisor-website/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/gvisor-website/main.go b/cmd/gvisor-website/main.go index 4c8e7c854..212256cd0 100644 --- a/cmd/gvisor-website/main.go +++ b/cmd/gvisor-website/main.go @@ -30,17 +30,24 @@ var redirects = map[string]string{ "/cl": "https://gvisor-review.googlesource.com/", "/issue": "https://github.com/google/gvisor/issues", "/issue/new": "https://github.com/google/gvisor/issues/new", + + // Redirects to compatibility docs. + "/c": "/docs/user_guide/compatibility", + "/c/linux/amd64": "/docs/user_guide/compatibility/amd64", } var prefixHelpers = map[string]string{ "cl": "https://gvisor-review.googlesource.com/c/gvisor/+/%s", "change": "https://gvisor.googlesource.com/gvisor/+/%s", "issue": "https://github.com/google/gvisor/issues/%s", + + // Redirects to compatibility docs. + "c/linux/amd64": "/docs/user_guide/compatibility/amd64/#%s", } var validId = regexp.MustCompile(`^[A-Za-z0-9-]*/?$`) -// redirectWithQuery redirects to the given target url preserving query parameters +// redirectWithQuery redirects to the given target url preserving query parameters. func redirectWithQuery(w http.ResponseWriter, r *http.Request, target string) { url := target if qs := r.URL.RawQuery; qs != "" { @@ -53,7 +60,7 @@ func redirectWithQuery(w http.ResponseWriter, r *http.Request, target string) { func prefixRedirectHandler(prefix, baseURL string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if p := r.URL.Path; p == prefix { - // redirect /prefix/ to /prefix + // Redirect /prefix/ to /prefix. http.Redirect(w, r, p[:len(p)-1], http.StatusFound) return } -- cgit v1.2.3