summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2014-03-24 15:56:28 +0100
committerKevin Chabowski <kevin@kch42.de>2014-03-24 15:56:28 +0100
commit79fed0e58753d50c613d15589b8f687474c2224c (patch)
treec81b102331e575f38d4b1b3f9f7722ea0e96c701 /main.go
downloadsimplechat-79fed0e58753d50c613d15589b8f687474c2224c.tar.gz
simplechat-79fed0e58753d50c613d15589b8f687474c2224c.tar.bz2
simplechat-79fed0e58753d50c613d15589b8f687474c2224c.zip
Initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go25
1 files changed, 25 insertions, 0 deletions
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)
+}