From e19d1462cb98c3f98ad02d989ff65d6f57cce8e4 Mon Sep 17 00:00:00 2001 From: Hannes Klinckaert Date: Mon, 12 Aug 2024 21:50:11 +0200 Subject: [PATCH] vingo: put things behind api route --- vingo/main.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vingo/main.go b/vingo/main.go index 1fcc5cd..b6503fc 100644 --- a/vingo/main.go +++ b/vingo/main.go @@ -25,24 +25,23 @@ func main() { db := database.Get() defer db.Close() - public := fiber.New(fiber.Config{}) + api := fiber.New(fiber.Config{}) - public.Use(cors.New(cors.Config{ + api.Use(cors.New(cors.Config{ AllowOrigins: corsAllowOrigins, AllowHeaders: "Origin, Content-Type, Accept, Access-Control-Allow-Origin", AllowCredentials: true, })) // Public routes - public.Post("/login", handlers.Login) - public.Get("/auth/callback", handlers.Callback) + { + api.Post("/login", handlers.Login) + api.Get("/auth/callback", handlers.Callback) - public.Post("/scans", handlers.ScanRegister) + api.Post("/scans", handlers.ScanRegister) - public.Get("/recent_scans", handlers.PublicRecentScans) + api.Get("/recent_scans", handlers.PublicRecentScans) - api := public.Group("/api", handlers.IsLoggedIn) - { api.Post("/logout", handlers.Logout) api.Get("/user", handlers.User) api.Get("/leaderboard", handlers.Leaderboard) @@ -64,7 +63,7 @@ func main() { } } - log.Println(public.Listen(":4000")) + log.Println(api.Listen(":4000")) } func setupFromEnv() {