-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 693 Bytes
/
main.go
File metadata and controls
35 lines (27 loc) · 693 Bytes
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
package main
import (
"fmt"
"log"
"net/http"
"github.com/v1nte/pubsub-go/database"
"github.com/v1nte/pubsub-go/logger"
"github.com/v1nte/pubsub-go/server"
)
func main() {
if err := database.Init(); err != nil {
log.Fatal("Could not connect to DB")
}
defer database.Close()
if err := logger.Init(); err != nil {
log.Fatal("Logger couldn't init")
}
logger.Log.Info("App Started")
defer logger.Log.Info("App shutdown")
defer logger.Log.Sync()
broker := server.NewBroker()
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
server.HandleWS(broker, w, r)
})
fmt.Println("Server runnin in :9876/ws")
log.Fatal(http.ListenAndServe(":9876", nil))
}