initial go implementation

This commit is contained in:
sm
2013-06-16 00:00:25 -07:00
parent 3c0128b9b9
commit d777a978ab
3 changed files with 152 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package main
import (
"code.google.com/p/go.net/websocket"
"flag"
"fmt"
"log"
"net/http"
)
var addr = flag.String("addr", ":8666", "http service address")
var static_files = flag.String("static", "./static", "location of static files")
func main() {
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(
fmt.Sprintf("%s/html", *static_files))))
http.Handle("/static/", http.StripPrefix("/static/",
http.FileServer(http.Dir(*static_files))))
http.Handle("/ws/game/", websocket.Handler(addPlayer))
go g.run()
err := http.ListenAndServe(*addr, nil)
if err != nil {
log.Fatal("unable to start server")
}
}