Skip to main content
Glama
gin.go901 B
package amis import ( "context" "fmt" "github.com/gin-gonic/gin" "github.com/weibaohui/k8m/pkg/constants" "github.com/weibaohui/kom/kom" ) func GetSelectedCluster(c *gin.Context) (string, error) { selectedCluster := c.GetString("cluster") if kom.Cluster(selectedCluster) == nil { return "", fmt.Errorf("cluster %s not found", selectedCluster) } return selectedCluster, nil } // GetLoginUser 获取当前登录用户名 func GetLoginUser(c *gin.Context) string { user := c.GetString(constants.JwtUserName) return user } func GetContextWithUser(c *gin.Context) context.Context { user := GetLoginUser(c) ctx := context.WithValue(c.Request.Context(), constants.JwtUserName, user) return ctx } func GetContextForAdmin() context.Context { // cfg := flag.Init() // todo 内部使用逻辑 ctx := context.WithValue(context.Background(), constants.JwtUserName, "admin") return ctx }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/weibaohui/k8m'

If you have feedback or need assistance with the MCP directory API, please join our Discord server