internal/play: support plain text response
Fixes golang/go#51181 Change-Id: I82f10320e86555a161cbfb5c5b79dfc331017003 Reviewed-on: https://go-review.googlesource.com/c/website/+/388016 Run-TryBot: Jamal Carvalho <jamal@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Jamal Carvalho <jamalcarvalho@google.com>
This commit is contained in:
Родитель
d6638d3d92
Коммит
832feb7309
|
@ -43,12 +43,22 @@ GET https://go.dev/play/p/asdfasdf
|
|||
body contains The Go Playground
|
||||
body contains About the Playground
|
||||
|
||||
GET https://go.dev/play/p/MAohLsrz7JQ.go
|
||||
header Content-Type == text/plain; charset=utf-8
|
||||
body !contains The Go Playground
|
||||
body !contains About the Playground
|
||||
body contains Hello, 世界
|
||||
|
||||
GET https://golang.google.cn/play/p/asdfasdf
|
||||
code == 500
|
||||
body contains Sorry, but shared playground snippets are not visible in China.
|
||||
body !contains The Go Playground
|
||||
body !contains About the Playground
|
||||
|
||||
GET https://golang.google.cn/play/p/MAohLsrz7JQ.go
|
||||
code == 500
|
||||
body contains Sorry, but shared playground snippets are not visible in China.
|
||||
|
||||
# These $GOROOT/*.md files should not serve.
|
||||
GET https://go.dev/CONTRIBUTING
|
||||
code == 404
|
||||
|
|
|
@ -35,6 +35,10 @@ func playHandler(site *web.Site) http.Handler {
|
|||
site.ServeError(w, r, errors.New("Sorry, but shared playground snippets are not visible in China."))
|
||||
return
|
||||
}
|
||||
if strings.HasSuffix(r.URL.Path, ".go") {
|
||||
simpleProxy(w, r, "https://"+backend(r)+strings.TrimPrefix(r.URL.Path, "/play"))
|
||||
return
|
||||
}
|
||||
site.ServePage(w, r, web.Page{
|
||||
"URL": r.URL.Path,
|
||||
"layout": "play",
|
||||
|
|
Загрузка…
Ссылка в новой задаче