go-tour: use playground package from go.talks for /compile handler
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/8839044
diff --git a/gotour/appengine.go b/gotour/appengine.go
index a410989..d48c1be 100644
--- a/gotour/appengine.go
+++ b/gotour/appengine.go
@@ -9,19 +9,18 @@
import (
"bufio"
"bytes"
- "fmt"
"io"
"net/http"
"appengine"
- "appengine/urlfetch"
+
+ _ "code.google.com/p/go.talks/pkg/playground"
)
const runUrl = "http://golang.org/compile"
func init() {
http.HandleFunc("/", rootHandler)
- http.HandleFunc("/compile", compileHandler)
err := serveScripts("js", "playground.js")
if err != nil {
panic(err)
@@ -38,30 +37,6 @@
}
}
-func compileHandler(w http.ResponseWriter, r *http.Request) {
- if err := passThru(w, r); err != nil {
- w.WriteHeader(http.StatusInternalServerError)
- fmt.Fprintln(w, "Compile server error.")
- }
-}
-
-func passThru(w io.Writer, req *http.Request) error {
- c := appengine.NewContext(req)
- client := urlfetch.Client(c)
- defer req.Body.Close()
- r, err := client.Post(runUrl, req.Header.Get("Content-type"), req.Body)
- if err != nil {
- c.Errorf("making POST request:", err)
- return err
- }
- defer r.Body.Close()
- if _, err := io.Copy(w, r.Body); err != nil {
- c.Errorf("copying response Body:", err)
- return err
- }
- return nil
-}
-
// prepContent returns a Reader that produces the content from the given
// Reader, but strips the prefix "#appengine: " from each line. It also drops
// any non-blank like that follows a series of 1 or more lines with the prefix.