-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 803 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
package main
import (
"log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/jaeyoung0509/goweb/database"
"github.com/jaeyoung0509/goweb/routes"
)
func setupRoutes(app *fiber.App) {
app.Get("/hello", routes.Hello)
app.Get("/login", routes.Login)
app.Get("/allbooks", routes.AllBooks)
app.Post("/addbook", routes.AddBook)
app.Post("/book", routes.Book)
app.Put("/update", routes.Update)
app.Delete("/delete", routes.Delete)
app.Post("/register", routes.Register)
}
func main() {
database.ConnectDb()
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowCredentials: true,
}))
setupRoutes(app)
app.Use(cors.New())
app.Use(func(c *fiber.Ctx) error {
return c.SendStatus(404) // => 404 "Not Found"
})
log.Fatal(app.Listen(":3000"))
}