micrach/gateway/controllers.go
2026-07-15 23:18:27 +04:00

22 lines
445 B
Go

package gateway
import (
"micrach/config"
"github.com/gofiber/fiber/v2"
)
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",
})
}