-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (31 loc) · 856 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
package main
import (
"fmt"
"log"
"time"
"github.com/drkgrntt/htmx-test/controllers"
"github.com/drkgrntt/htmx-test/database"
"github.com/drkgrntt/htmx-test/utils"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main() {
config, err := utils.LoadConfig(".")
if err != nil {
log.Fatal("? Could not load environment variables", err)
}
database.Connect()
app := fiber.New(fiber.Config{
Views: html.New("./views", ".html"),
ViewsLayout: "layout/main",
PassLocalsToViews: true,
})
app.Use(func(c *fiber.Ctx) error {
c.Locals("IsAdmin", config.Environment == "development")
c.Locals("Year", time.Now().Year())
c.Locals("Environment", config.Environment)
return c.Next()
})
controllers.InitializeControllers(app)
log.Fatal(app.Listen(fmt.Sprintf(":%s", config.ServerPort)))
}