liuhaijun 3f5f28d785 add sheduling agent
Change-Id: I89f35fb3984044c57f10727432755012542f9fd8
2023-11-16 10:55:57 +00:00

27 lines
465 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
"github.com/golang/glog"
"regexp"
)
func AuthorizationHandler() gin.HandlerFunc {
return func(c *gin.Context) {
match, _ := regexp.MatchString("/healthz", c.Request.RequestURI)
if match {
c.Next()
return
}
_, exist := c.Get(LoginUserKey)
if !exist {
glog.Fatal("Authorization middleware should work together with Authentication middleware")
c.Next()
return
}
c.Next()
}
}