From 79fed0e58753d50c613d15589b8f687474c2224c Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Mon, 24 Mar 2014 15:56:28 +0100 Subject: Initial commit --- main.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go new file mode 100644 index 0000000..c18959a --- /dev/null +++ b/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "flag" + "github.com/gorilla/mux" + "net/http" +) + +var ( + laddr = flag.String("laddr", ":8080", "Listen on this address") + tplpath = flag.String("tplpath", "tpls", "Path to templates") + staticpath = flag.String("staticpath", "static", "Path to static page elements") +) + +func main() { + flag.Parse() + + r := mux.NewRouter() + r.HandleFunc("/", Home) + r.PathPrefix("/static").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(*staticpath)))) + r.HandleFunc("/chat/{chatroom}/", Chatpage) + r.HandleFunc("/chat/{chatroom}/socket", AcceptWebSock) + http.Handle("/", r) + http.ListenAndServe(*laddr, nil) +} -- cgit v1.2.3-70-g09d2