34 lines
888 B
Go
34 lines
888 B
Go
package router
|
|
|
|
import (
|
|
"clickandjoin.app/managementsystem/modules/config"
|
|
"clickandjoin.app/managementsystem/routers/api/v1/chats"
|
|
"clickandjoin.app/managementsystem/routers/api/v1/users"
|
|
"clickandjoin.app/managementsystem/routers/api/v1/wssessions"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func SetupRoutes(app *fiber.App) {
|
|
v1 := app.Group("/v1")
|
|
|
|
us := v1.Group("/users")
|
|
us.Get("/", ApiKeyValidation, users.GetAllUsers)
|
|
us.Get("/usersignupprocesses", ApiKeyValidation, users.GetAllUserSignUpProcesses)
|
|
|
|
wss := v1.Group("/wssessions")
|
|
wss.Get("/", ApiKeyValidation, wssessions.GetAllWsSessions)
|
|
|
|
c := v1.Group("/chats")
|
|
c.Get("/", ApiKeyValidation, chats.GetAllChats)
|
|
}
|
|
|
|
func ApiKeyValidation(c *fiber.Ctx) error {
|
|
apiKey := c.GetReqHeaders()["X-Ms-Api"]
|
|
|
|
if apiKey != config.Cfg.ManagementSystemApiKey {
|
|
return c.SendStatus(fiber.StatusUnauthorized)
|
|
}
|
|
|
|
return c.Next()
|
|
}
|