[release-branch.go1.2] go-tour: use new socket interface
««« CL 100090043 / a8f927c18a86
go-tour: use new socket interface
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100090043
»»»
TBR=rsc
CC=golang-codereviews
https://golang.org/cl/97030044
diff --git a/gotour/local.go b/gotour/local.go
index 647aab6..31cb4d5 100644
--- a/gotour/local.go
+++ b/gotour/local.go
@@ -14,6 +14,7 @@
"log"
"net"
"net/http"
+ "net/url"
"os"
"os/exec"
"path/filepath"
@@ -104,6 +105,9 @@
http.Handle("/static/", fs)
http.Handle("/talks/", fs)
+ origin := &url.URL{Scheme: "http", Host: host + ":" + port}
+ http.Handle(socketPath, socket.NewHandler(origin))
+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
if err := renderTour(w); err != nil {
@@ -114,8 +118,6 @@
http.Error(w, "not found", 404)
})
- http.Handle(socketPath, socket.Handler)
-
err = serveScripts(filepath.Join(root, "js"), "SocketTransport")
if err != nil {
log.Fatal(err)