micrach/gateway/controllers.go

22 lines
444 B
Go
Raw Normal View History

package gateway
import (
"micrach/config"
2026-07-16 15:25:23 +03:00
"github.com/gofiber/fiber/v3"
)
2026-07-16 15:25:23 +03:00
func Ping(c fiber.Ctx) error {
headerValues := c.GetReqHeaders()["Authorization"]
headerKey := ""
if len(headerValues) > 0 {
headerKey = headerValues[len(headerValues)-1]
}
if config.App.Gateway.ApiKey != headerKey {
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"error": "Unauthorized"})
}
return c.JSON(fiber.Map{
"message": "pong",
})
}