-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (31 loc) · 789 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 (
"i9chat/initializers"
"i9chat/routes/authRoutes"
"i9chat/routes/chatRoutes/dmChatRoutes"
"i9chat/routes/chatRoutes/groupChatRoutes"
"i9chat/routes/userRoutes"
"log"
"os"
"github.com/gofiber/contrib/websocket"
"github.com/gofiber/fiber/v2"
)
func init() {
if err := initializers.InitApp(); err != nil {
log.Fatal(err)
}
}
func main() {
app := fiber.New()
app.Use(func(c *fiber.Ctx) error {
if websocket.IsWebSocketUpgrade(c) {
return c.Next()
}
return fiber.ErrUpgradeRequired
})
app.Route("/api/auth", authRoutes.Init)
app.Route("/api/app/user", userRoutes.Init)
app.Route("/api/app/dm_chat", dmChatRoutes.Init)
app.Route("/api/app/group_chat", groupChatRoutes.Init)
log.Fatalln(app.Listen("0.0.0.0:" + os.Getenv("PORT")))
}