-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (31 loc) · 848 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
package main
import (
"album-list/database"
"album-list/handlers"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main() {
database.ConnectDb()
engine := html.New("./views", ".html")
app := fiber.New(fiber.Config{
Views: engine,
ViewsLayout: "layouts/main", // add this to config
})
setupRoutes(app)
app.Static("/", "./public")
app.Listen(":3000")
}
func setupRoutes(app *fiber.App) {
app.Get("/", handlers.ListAlbums)
app.Get("/health", func(c *fiber.Ctx) error {
return c.JSON(http.StatusOK)
})
app.Get("/album", handlers.NewAlbumView)
app.Post("/album", handlers.AddAlbum)
app.Get("/album/:id", handlers.ShowAlbum)
app.Get("/album/:id/edit", handlers.EditAlbum)
app.Patch("/album/:id", handlers.UpdateAlbum)
app.Delete("/album/:id", handlers.DeleteAlbum)
}