-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (33 loc) · 854 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 (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/joho/godotenv"
"github.com/pianisimo/cards-api/routes"
"log"
"os"
)
func main() {
initApp()
}
func initApp() {
err := godotenv.Load()
if err != nil {
log.Fatalf("error while loading .env file: %v", err)
}
app := fiber.New()
app.Use(logger.New())
setupRoutes(app)
log.Fatal(app.Listen(os.Getenv("ADDRESS") + os.Getenv("PORT")))
}
func setupRoutes(app *fiber.App) {
app.Post("/create-new-deck", routes.CreateNewDeck)
app.Put("/draw-cards", routes.DrawCards)
app.Get("/open-deck/:id", routes.OpenDeck)
app.Get("/get-all-decks", routes.GetAllDecks)
// TODO
/*
Setup more routes, public routes should in routes/public
Private routes that requires authentication or admin permission should go in routes/private
*/
}