-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 883 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
41
42
43
package main
import (
"dwelt/src/config"
"dwelt/src/handler"
"dwelt/src/model/dao"
"dwelt/src/service/usrserv"
"dwelt/src/ws/chat"
"flag"
"log/slog"
"net/http"
)
var port = flag.String("port", ":8080", "port to listen on")
// @title Dwelt API
// @version 0.0.1
// @description This is the API for the Dwelt application.
func main() {
slog.SetLogLoggerLevel(slog.LevelDebug)
flag.Parse()
config.InitCfg()
db := dao.InitDB()
hub := chat.NewHub()
go hub.Run()
userDao := dao.NewUserDao(db)
userService := usrserv.NewUserService(hub, userDao)
userController := handler.NewUserController(userService)
userController.InitHandlers(hub)
userService.StartHandlingMessages()
server := &http.Server{
Addr: *port,
}
slog.Info("Starting server on port " + *port)
err := server.ListenAndServe()
if err != nil {
slog.Error("error starting server: ", err)
}
}