-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (31 loc) · 833 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
package main
import (
"log"
"github.com/4fort/fiber_gorm/database"
"github.com/4fort/fiber_gorm/routes"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/logger"
)
func welcome(c fiber.Ctx) error {
return c.SendString("Hello, World! OTINLKAHGDJKHAGWSDKLJJGH")
}
func setupRoutes(app *fiber.App) {
api := app.Group("/api")
// welcome endpoint
api.Get("/", welcome)
// user endpoint
api.Post("/users", routes.CreateUser)
api.Get("/users", routes.GetUsers)
api.Get("/users/:id", routes.GetUser)
api.Put("/users/:id", routes.UpdateUser)
api.Delete("/users/:id", routes.DeleteUser)
}
func main() {
database.ConnectDb()
app := fiber.New()
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
setupRoutes(app)
log.Fatal(app.Listen(":3000"))
}