middleware

package
v0.0.0-...-8f0f6a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KubeClientCtxKey    = "kubeClient"
	DynamicClientCtxKey = "dynClient"
	TokenCtxKey         = "token"
)
View Source
const (
	PageCtxKey  = "page"
	LimitCtxKey = "limit"
)
View Source
const (
	ClusterCtxKey = "cluster"
)
View Source
const (
	LoggerCtxKey = "logger"
)
View Source
const (
	WebsocketTokenHeader = "Sec-Websocket-Protocol"
)

Variables

This section is empty.

Functions

func AddErrorToContext

func AddErrorToContext(c *gin.Context, err error) bool

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

func GetCluster(c *gin.Context) (string, bool)

GetCluster retrieves the cluster from the gin.Context.

func GetDynClient

func GetDynClient(c *gin.Context) (client.Client, error)

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 GetLogger

func GetLogger(c *gin.Context) (*zap.Logger, error)

GetLogger retrieves the logger 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL