forked from kobeld/gochatting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
31 lines (25 loc) · 737 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"code.google.com/p/go.net/websocket"
"github.com/kobeld/gochatting/handlers"
"github.com/kobeld/gochatting/wscon"
. "github.com/paulbellamy/mango"
"net/http"
)
func main() {
l, r := handlers.LayoutAndRenderer()
s := new(Stack)
s.Middleware(l, r)
http.Handle("/chat", websocket.Handler(wscon.BuildConnection))
http.HandleFunc("/join", s.HandlerFunc(handlers.Join))
http.HandleFunc("/", s.HandlerFunc(handlers.Home))
http.HandleFunc("/public/", assetsHandler)
go wscon.InitChatRoom()
err := http.ListenAndServe(":5050", nil)
if err != nil {
panic("ListenAndServe: " + err.Error())
}
}
func assetsHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[len("/"):])
}