add check roles
This commit is contained in:
17
mw/check_admin_role.go
Normal file
17
mw/check_admin_role.go
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user