Files
astra-users/mw/check_admin_role.go
2023-07-05 18:37:24 +03:00

18 lines
308 B
Go

package mw
import (
"github.com/labstack/echo/v4"
"net/http"
)
func CheckAdminRole(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
role := c.Request().Header.Get("UserRole")
if role != "admin" {
return c.NoContent(http.StatusUnauthorized)
}
return next(c)
}
}