diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-01-07 12:25:43 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-07 12:25:43 -0800 |
commit | c8d0fd7094ee0152a87667e3224e765a32522a09 (patch) | |
tree | cbae07f232078ea75ded6d3454f40c4d7ba385be | |
parent | 4c5f36e7bd4781fc9984ef4fdf98009b5ec4cb4c (diff) | |
parent | a0037b8976d1ea482e1545adfa65403ca43dbb1a (diff) |
Merge pull request #5213 from prattmic:pkg.go.dev
PiperOrigin-RevId: 350614888
-rw-r--r-- | website/cmd/server/main.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/website/cmd/server/main.go b/website/cmd/server/main.go index 84a576858..601ccac5e 100644 --- a/website/cmd/server/main.go +++ b/website/cmd/server/main.go @@ -171,7 +171,7 @@ func redirectHandler(target string) http.Handler { }) } -// redirectRedirects registers redirect http handlers. +// registerRedirects registers redirect http handlers. func registerRedirects(mux *http.ServeMux) { for prefix, baseURL := range prefixHelpers { p := "/" + prefix + "/" @@ -180,6 +180,17 @@ func registerRedirects(mux *http.ServeMux) { for path, redirect := range redirects { mux.Handle(path, hostRedirectHandler(wrappedHandler(redirectHandler(redirect)))) } + registerModuleDocRedirects(http.DefaultServeMux) +} + +// registerModuleDocs registers redirect http handlers to redirect module paths +// directly to their docs on pkg.go.dev. +func registerModuleDocRedirects(mux *http.ServeMux) { + const prefix = "/gvisor/" + mux.Handle(prefix, hostRedirectHandler(wrappedHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + pkg := r.URL.Path[len(prefix):] + redirectWithQuery(w, r, fmt.Sprintf("https://pkg.go.dev/gvisor.dev/gvisor/%s", pkg)) + })))) } // registerStatic registers static file handlers. |