liuhaijun e94826ce29 add server
Change-Id: I0760f17f6a01c0121b59fcbfafc666032dbc30af
2024-09-19 09:44:15 +00:00

28 lines
400 B
Go

package middleware
import (
"github.com/gin-gonic/gin"
)
const (
CLUSTERID = "clusterId"
NAMESPACE = "namespace"
)
func AppContextHandler() gin.HandlerFunc {
return func(c *gin.Context) {
ns := c.Request.Header.Get("namespace")
if len(ns) != 0 {
c.Set(NAMESPACE, ns)
}
clusterId := c.Param("cluster")
if len(clusterId) != 0 {
c.Set(CLUSTERID, clusterId)
}
c.Next()
}
}