cmd/golangorg: redirect go2goplay.golang.org to go.dev/play Redirects go2goplay.golang.org to go.dev/play to preserve old links (e.g., in official Go blog posts) after the go2goplay App Engine instance is turned down. This handles both the root domain and snippet links by redirecting them to their go.dev/play equivalents (preserving the path). Updates golang/go#48517 Change-Id: If6110d0a2968e05573d7bcd751c68947130f34c9 Reviewed-on: https://go-review.googlesource.com/c/website/+/803640 Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicholas Husin <nsh@golang.org>
diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go index 8727c49..7985d42 100644 --- a/cmd/golangorg/server.go +++ b/cmd/golangorg/server.go
@@ -228,6 +228,7 @@ mux.Handle("play.go.dev/", redirectPrefix("https://go.dev/play/")) mux.Handle("talks.go.dev/", redirectPrefix("https://go.dev/talks/")) mux.Handle("tour.go.dev/", redirectPrefix("https://go.dev/tour/")) + mux.Handle("go2goplay.golang.org/", redirectPrefix("https://go.dev/play/")) // m.golang.org is an old shortcut for golang.org mail. // Gmail itself can serve this redirect, but only on HTTP (not HTTPS). @@ -498,14 +499,15 @@ } var validHosts = map[string]bool{ - "golang.org": true, - "golang.google.cn": true, - "beta.golang.org": true, - "blog.golang.org": true, - "m.golang.org": true, - "talks.golang.org": true, - "tip.golang.org": true, - "tour.golang.org": true, + "golang.org": true, + "golang.google.cn": true, + "beta.golang.org": true, + "blog.golang.org": true, + "m.golang.org": true, + "talks.golang.org": true, + "tip.golang.org": true, + "tour.golang.org": true, + "go2goplay.golang.org": true, "go.dev": true, "blog.go.dev": true,
diff --git a/cmd/golangorg/testdata/web.txt b/cmd/golangorg/testdata/web.txt index c3bd5d6..2fe3c95 100644 --- a/cmd/golangorg/testdata/web.txt +++ b/cmd/golangorg/testdata/web.txt
@@ -493,3 +493,12 @@ GET https://tip.golang.org/doc/next body contains <h1>Next Release Notes Draft</h1> + +GET https://go2goplay.golang.org/ +code == 301 +redirect == https://go.dev/play/ + +GET https://go2goplay.golang.org/p/abc +code == 301 +redirect == https://go.dev/play/p/abc +