-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
49 lines (38 loc) · 875 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
44
45
46
47
48
49
package main
import (
"embed"
"net/http"
"ricin9/fiber-chat/config"
"ricin9/fiber-chat/handlers"
"ricin9/fiber-chat/utils"
"log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
)
var (
//go:embed static
embedStaticDir embed.FS
//go:embed migrations/*
embedMigrationsDir embed.FS
)
func main() {
config.Setup()
utils.Migrate(embedMigrationsDir)
// Create fiber app
app := fiber.New(fiber.Config{
PassLocalsToViews: true,
})
// Global Middleware
app.Use(recover.New())
app.Use(logger.New())
// Routes
handlers.Setup(app)
app.Use("/", filesystem.New(filesystem.Config{
Root: http.FS(embedStaticDir),
PathPrefix: "/static",
}))
// Listen on port $PORT or 3000
log.Fatal(app.Listen(config.Port))
}