diff --git a/cmd/godoc/appinit.go b/cmd/godoc/appinit.go index 996b2b85..9604e9b8 100644 --- a/cmd/godoc/appinit.go +++ b/cmd/godoc/appinit.go @@ -52,7 +52,6 @@ func init() { readTemplates() initHandlers() registerPublicHandlers(http.DefaultServeMux) - registerPlaygroundHandlers(http.DefaultServeMux) // initialize default directory tree with corresponding timestamp. initFSTree() diff --git a/cmd/godoc/main.go b/cmd/godoc/main.go index 618a74ea..641b7317 100644 --- a/cmd/godoc/main.go +++ b/cmd/godoc/main.go @@ -287,7 +287,6 @@ func main() { } registerPublicHandlers(http.DefaultServeMux) - registerPlaygroundHandlers(http.DefaultServeMux) // Initialize default directory tree with corresponding timestamp. // (Do it in a goroutine so that launch is quick.) diff --git a/cmd/godoc/play-appengine.go b/cmd/godoc/play-appengine.go deleted file mode 100644 index 9e351d1a..00000000 --- a/cmd/godoc/play-appengine.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// App Engine godoc Playground functionality. - -// +build appengine - -package main - -import ( - "io" - "net/http" - - "appengine" - "appengine/urlfetch" -) - -func bounceToPlayground(w http.ResponseWriter, req *http.Request) { - c := appengine.NewContext(req) - client := urlfetch.Client(c) - url := playgroundBaseURL + req.URL.Path - defer req.Body.Close() - resp, err := client.Post(url, req.Header.Get("Content-type"), req.Body) - if err != nil { - http.Error(w, "Internal Server Error", 500) - c.Errorf("making POST request: %v", err) - return - } - defer resp.Body.Close() - if _, err := io.Copy(w, resp.Body); err != nil { - http.Error(w, "Internal Server Error", 500) - c.Errorf("making POST request: %v", err) - } -} diff --git a/cmd/godoc/play-local.go b/cmd/godoc/play-local.go deleted file mode 100644 index 637ce5e1..00000000 --- a/cmd/godoc/play-local.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Stand-alone godoc Playground functionality. - -// +build !appengine - -package main - -import ( - "io" - "net/http" - "net/url" -) - -var playgroundScheme, playgroundHost string - -func init() { - u, err := url.Parse(playgroundBaseURL) - if err != nil { - panic(err) - } - playgroundScheme = u.Scheme - playgroundHost = u.Host -} - -// bounceToPlayground forwards the request to play.golang.org. -func bounceToPlayground(w http.ResponseWriter, req *http.Request) { - defer req.Body.Close() - req.URL.Scheme = playgroundScheme - req.URL.Host = playgroundHost - resp, err := http.Post(req.URL.String(), req.Header.Get("Content-type"), req.Body) - if err != nil { - http.Error(w, err.Error(), 500) - return - } - w.WriteHeader(resp.StatusCode) - io.Copy(w, resp.Body) - resp.Body.Close() -} diff --git a/cmd/godoc/play.go b/cmd/godoc/play.go index 47a11f6c..4e994292 100644 --- a/cmd/godoc/play.go +++ b/cmd/godoc/play.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Common Playground functionality. - package main import ( @@ -11,19 +9,11 @@ import ( "fmt" "go/format" "net/http" + + _ "code.google.com/p/go.talks/pkg/playground" ) -// The server that will service compile and share requests. -const playgroundBaseURL = "http://play.golang.org" - -func registerPlaygroundHandlers(mux *http.ServeMux) { - if *showPlayground { - mux.HandleFunc("/compile", bounceToPlayground) - mux.HandleFunc("/share", bounceToPlayground) - } else { - mux.HandleFunc("/compile", disabledHandler) - mux.HandleFunc("/share", disabledHandler) - } +func init() { http.HandleFunc("/fmt", fmtHandler) }