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() } }