summaryrefslogtreecommitdiff
path: root/pages.go
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2014-03-25 15:31:57 +0100
committerKevin Chabowski <kevin@kch42.de>2014-03-25 15:31:57 +0100
commit3aa1c450a3376a4339354579f90b6111b963c78a (patch)
tree00843a98726d59ceca510f005cff093c5d9a8421 /pages.go
parent734f6e92016ca875ad56ff7e423a0872648c012f (diff)
downloadsimplechat-3aa1c450a3376a4339354579f90b6111b963c78a.tar.gz
simplechat-3aa1c450a3376a4339354579f90b6111b963c78a.tar.bz2
simplechat-3aa1c450a3376a4339354579f90b6111b963c78a.zip
Some placeholders for the HTML pages
Diffstat (limited to 'pages.go')
-rw-r--r--pages.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pages.go b/pages.go
new file mode 100644
index 0000000..40c2c21
--- /dev/null
+++ b/pages.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "html/template"
+ "net/http"
+ "path"
+)
+
+var (
+ TplHome, TplChat *template.Template
+)
+
+type ChatpageData struct {
+ Websock string
+}
+
+func PrepTemplates() {
+ TplHome = template.Must(template.ParseFiles(path.Join(*tplpath, "home.html")))
+ TplChat = template.Must(template.ParseFiles(path.Join(*tplpath, "chat.html")))
+}
+
+func Home(rw http.ResponseWriter, req *http.Request) {
+ TplHome.Execute(rw, nil) // TODO: Should we log the error?
+}
+
+func Chatpage(rw http.ResponseWriter, req *http.Request) {
+ TplChat.Execute(rw, ChatpageData{"ws://" + req.Host + req.URL.Path + "socket"})
+}