Source File
playground.go
Belonging Package
golang.org/x/pkgsite/internal/frontend
package frontend
import (
)
var playgroundURL = &url.URL{Scheme: "https", Host: "play.golang.org"}
func ( http.ResponseWriter, int) {
http.Error(, http.StatusText(), )
}
func ( *Server) ( http.ResponseWriter, *http.Request) {
makePlaygroundProxy(playgroundURL).ServeHTTP(, )
}
func ( *url.URL) *httputil.ReverseProxy {
return &httputil.ReverseProxy{
Director: func( *http.Request) {
.Header.Add("X-Forwarded-Host", .Host)
.Header.Add("X-Origin-Host", .Host)
.Host = .Host
.URL.Scheme = .Scheme
.URL.Host = .Host
.URL.Path = strings.TrimPrefix(.URL.Path, "/play")
},
ErrorHandler: func( http.ResponseWriter, *http.Request, error) {
log.Errorf(.Context(), "ERROR playground proxy error: %v", )
httpErrorStatus(, http.StatusInternalServerError)
},
}
}
type fmtResponse struct {
Body string
Error string
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |