initial go implementation
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user