-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 759 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
32
33
34
35
36
37
38
39
40
package main
import (
"log"
"net/http"
r "github.com/dancannon/gorethink"
)
/*Channel is a struct type */
type Channel struct {
ID string `json:"id" gorethink:"id,omitempty"`
Name string `json:"name" gorethink:"name"`
}
/*User struct*/
type User struct {
ID string `gorethink:"id,omitempty"`
Name string `gorethink:"name"`
}
func main() {
session, err := r.Connect(r.ConnectOpts{
Address: "172.17.0.2:28015",
Database: "realtime_go_db",
})
if err != nil {
log.Panic(err.Error())
}
router := NewRouter(session)
router.Handle("channel add", addChannel)
router.Handle("channel subscribe", subscribeChannel)
router.Handle("channel unsubscribe", unsubscribeChannel)
http.Handle("/", router)
http.ListenAndServe(":8081", nil)
}