diff options
| author | Russ Cox <rsc@golang.org> | 2021-11-09 12:50:51 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-11-22 16:40:00 +0000 |
| commit | 961523a99713328508cc63167192db63311e474b (patch) | |
| tree | 54f5d1604b48e7e9ec77b2551a22dab33dcb614a /cmd/golangorg/server.go | |
| parent | 36da86b3f128315a7a2bb8af286aa1d2afe4cf8a (diff) | |
| download | go-x-website-961523a99713328508cc63167192db63311e474b.tar.xz | |
go.dev: add /play
This is a replacement for the UI of play.golang.org,
although it still uses play.golang.org as the backend
and probably always will, to keep the playground backend
deployment separate from the rest of the web site.
Change-Id: Ia39000e80368b98d9cc273d246f2c83670fbacc4
Reviewed-on: https://go-review.googlesource.com/c/website/+/364815
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Diffstat (limited to 'cmd/golangorg/server.go')
| -rw-r--r-- | cmd/golangorg/server.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go index 5dfe069b..889e33b4 100644 --- a/cmd/golangorg/server.go +++ b/cmd/golangorg/server.go @@ -207,6 +207,8 @@ func NewHandler(contentDir, goroot string) http.Handler { if err := blog.RegisterFeeds(godevMux, "", godevSite); err != nil { log.Fatalf("blog: %v", err) } + mux.Handle("go.dev/play", playHandler(godevSite)) + mux.Handle("go.dev/play/p/", playHandler(godevSite)) mux.Handle("go.dev/", addCSP(godevMux)) mux.Handle("blog.golang.org/", redirectPrefix("https://go.dev/blog/")) @@ -215,6 +217,7 @@ func NewHandler(contentDir, goroot string) http.Handler { if runningOnAppEngine { appEngineSetup(site, chinaSite, mux) } + proxy.RegisterHandlers(mux) dl.RegisterHandlers(mux, site, "golang.org", datastoreClient, memcacheClient) dl.RegisterHandlers(mux, chinaSite, "golang.google.cn", datastoreClient, memcacheClient) @@ -224,6 +227,16 @@ func NewHandler(contentDir, goroot string) http.Handler { return h } +func playHandler(godevSite *web.Site) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + godevSite.ServePage(w, r, web.Page{ + "URL": r.URL.Path, + "layout": "play", + "title": "Go Playground", + }) + }) +} + // newSite creates a new site for a given content and goroot file system pair // and registers it in mux to handle requests for host. // If host is the empty string, the registrations are for the wildcard host. @@ -340,7 +353,6 @@ func appEngineSetup(site, chinaSite *web.Site, mux *http.ServeMux) { memcacheClient = memcache.New(redisAddr) short.RegisterHandlers(mux, "golang.org", datastoreClient, memcacheClient) - proxy.RegisterHandlers(mux, googleCN) log.Println("AppEngine initialization complete") } |
