Skip to content

Commit 0750b08

Browse files
committed
The Go web sites are consolidating into go.dev, including the playground at https://go.dev/play. Redirect users (but not API requests) to the new URL. Change-Id: I9bc4338568d1afd5916a84ec4d26cce2133b9ea0 Reviewed-on: https://go-review.googlesource.com/c/playground/+/364816 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org>
1 parent 8bb1e2e commit 0750b08

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

edit.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,17 @@ func (s *server) handleEdit(w http.ResponseWriter, r *http.Request) {
7878
return
7979
}
8080
}
81+
82+
if r.Host == hostname {
83+
// The main playground is now on go.dev/play.
84+
http.Redirect(w, r, "https://go.dev/play"+r.URL.Path, http.StatusFound)
85+
return
86+
}
87+
8188
w.Header().Set("Content-Type", "text/html; charset=utf-8")
8289
data := &editData{
8390
Snippet: snip,
8491
Share: allowShare(r),
85-
Analytics: r.Host == hostname,
8692
GoVersion: runtime.Version(),
8793
Gotip: s.gotip,
8894
Examples: s.examples.examples,

server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestEdit(t *testing.T) {
7272
{"foo.play.golang.org to play.golang.org", http.MethodGet, "https://foo.play.golang.org", http.StatusFound, map[string]string{"Location": "https://play.golang.org"}, nil},
7373
{"Non-existent page", http.MethodGet, "https://play.golang.org/foo", http.StatusNotFound, nil, nil},
7474
{"Unknown snippet", http.MethodGet, "https://play.golang.org/p/foo", http.StatusNotFound, nil, nil},
75-
{"Existing snippet", http.MethodGet, "https://play.golang.org/p/" + id, http.StatusOK, nil, nil},
75+
{"Existing snippet", http.MethodGet, "https://play.golang.org/p/" + id, http.StatusFound, nil, nil},
7676
{"Plaintext snippet", http.MethodGet, "https://play.golang.org/p/" + id + ".go", http.StatusOK, nil, barBody},
7777
{"Download snippet", http.MethodGet, "https://play.golang.org/p/" + id + ".go?download=true", http.StatusOK, map[string]string{"Content-Disposition": fmt.Sprintf(`attachment; filename="%s.go"`, id)}, barBody},
7878
}

0 commit comments

Comments
 (0)