mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 07:51:14 +00:00
23 lines
452 B
Go
23 lines
452 B
Go
package middleware
|
|
|
|
import (
|
|
"nysoure/server/model"
|
|
"os"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
func DevMiddleware() func(c fiber.Ctx) error {
|
|
AccessKey := os.Getenv("DEV_ACCESS_KEY")
|
|
return func(c fiber.Ctx) error {
|
|
if AccessKey == "" {
|
|
return model.NewUnAuthorizedError("Unauthorized")
|
|
}
|
|
providedKey := c.Get("X-DEV-ACCESS-KEY")
|
|
if providedKey != AccessKey {
|
|
return model.NewUnAuthorizedError("Unauthorized")
|
|
}
|
|
return c.Next()
|
|
}
|
|
}
|