-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (39 loc) · 1001 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
package main
import (
"log"
"os"
"github.com/gabriel-kimutai/ano2tes/controller"
"github.com/gabriel-kimutai/ano2tes/database"
"github.com/gabriel-kimutai/ano2tes/middleware"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/template/html/v2"
)
func main() {
database.ConnectDB()
file, err := os.OpenFile("out.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("Failed to open file: %v", err)
}
engine := html.New("./views", ".html")
app := fiber.New(
fiber.Config{
Views: engine,
},
)
logger := logger.New(
logger.Config{
Output: file,
},
)
app.Static("/static", "./public")
app.Use(logger)
app.Get("/", controller.Root)
// User route
app.Get("/user", middleware.RequireAuth, controller.User)
app.Post("/user", controller.UserCreate)
app.Get("/login", controller.LoginPage)
app.Post("/login", controller.UserLogin)
app.Get("/logout", controller.UserLogout)
app.Listen(":3000")
}