Documentation ¶
Index ¶
- Constants
- func AddErrorToContext(c *gin.Context, err error) bool
- func ClusterMiddleware() gin.HandlerFunc
- func ErrorHandlingMiddleware() gin.HandlerFunc
- func GetCluster(c *gin.Context) (string, bool)
- func GetDynClient(c *gin.Context) (client.Client, error)
- func GetKubeClient(c *gin.Context) (kubernetes.Interface, error)
- func GetLogger(c *gin.Context) (*zap.Logger, error)
- func LoggerMiddleware(baseLogger *zap.Logger) gin.HandlerFunc
- func PaginationMiddleware() gin.HandlerFunc
- func TokenAuthMiddleware(tokenProvider auth.TokenProvider, scheme *runtime.Scheme) gin.HandlerFunc
Constants ¶
const ( KubeClientCtxKey = "kubeClient" DynamicClientCtxKey = "dynClient" TokenCtxKey = "token" )
const ( PageCtxKey = "page" LimitCtxKey = "limit" )
const (
ClusterCtxKey = "cluster"
)
const (
LoggerCtxKey = "logger"
)
const (
WebsocketTokenHeader = "Sec-Websocket-Protocol"
)
Variables ¶
This section is empty.
Functions ¶
func AddErrorToContext ¶
AddErrorToContext checks if the error is non-nil and adds it to the Gin context if so.
func ClusterMiddleware ¶
func ClusterMiddleware() gin.HandlerFunc
ClusterMiddleware retrieves the cluster based on capp and adds it to the request context.
func ErrorHandlingMiddleware ¶
func ErrorHandlingMiddleware() gin.HandlerFunc
ErrorHandlingMiddleware handles errors and sends appropriate responses.
func GetCluster ¶
GetCluster retrieves the cluster from the gin.Context.
func GetDynClient ¶
GetDynClient retrieves the dynamic client from the gin.Context.
func GetKubeClient ¶
func GetKubeClient(c *gin.Context) (kubernetes.Interface, error)
GetKubeClient retrieves the Kubernetes client from the gin.Context.
func LoggerMiddleware ¶
func LoggerMiddleware(baseLogger *zap.Logger) gin.HandlerFunc
LoggerMiddleware is a middleware that initializes a logger and sets it in the request context. The logger is initialized with a default "unknown" user. This middleware should be applied globally to ensure the logger is available in the context for all requests.
func PaginationMiddleware ¶
func PaginationMiddleware() gin.HandlerFunc
PaginationMiddleware is a middleware for extracting and setting pagination parameters from the request context
func TokenAuthMiddleware ¶
func TokenAuthMiddleware(tokenProvider auth.TokenProvider, scheme *runtime.Scheme) gin.HandlerFunc
TokenAuthMiddleware validates the Authorization header and sets up Kubernetes client.
Types ¶
This section is empty.