diff options
author | Ian Lewis <ianmlewis@gmail.com> | 2019-04-03 01:48:18 -0400 |
---|---|---|
committer | Ian Lewis <ianlewis@google.com> | 2019-04-03 16:16:45 +0900 |
commit | 5f7f96b50bf797cac2fb40262c7b69f8ad7025f9 (patch) | |
tree | 31f3be7d2e59a10459fe481ed1ee15aee56b90be /cmd/gvisor-website/main.go | |
parent | c061aef8d9044a3dda694a36e6d881d2eab6ee83 (diff) |
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
Diffstat (limited to 'cmd/gvisor-website/main.go')
-rw-r--r-- | cmd/gvisor-website/main.go | 11 |
1 files 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 } |