forked from unownone/go-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (34 loc) · 756 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
package main
import (
"fmt"
"os"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/joho/godotenv"
"github.com/unownone/go-chat/routes"
)
func main() {
err := godotenv.Load()
if os.Getenv("APP_ENV") == "development" {
if err != nil {
fmt.Println("Error loading .env file")
}
}
app := fiber.New(*getConfig())
app.Use(cors.New(cors.Config{
AllowCredentials: true,
}))
// Auth Routes
routes.Auth("/api/v1/auth", app)
// Chat Routes
routes.Chat("/api/v1/chat", app)
app.Listen(os.Getenv("HOST") + ":" + os.Getenv("PORT"))
}
func getConfig() *fiber.Config {
return &fiber.Config{
Prefork: true,
ServerHeader: "Go-Chat-Server",
AppName: "Go-Chat",
Immutable: true,
}
}