middlewares

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(config types.ICORSConfigurer) types.Middleware

func CsrfMiddleware

func CsrfMiddleware(config types.ICsrfConfig) types.Middleware

func HTTPSRedirectMiddleware

func HTTPSRedirectMiddleware() types.Middleware

func JWTMiddleware

func JWTMiddleware(jwtConfig types.IJWTConfig) types.Middleware

func LoggingMiddleware

func LoggingMiddleware(logger *zap.Logger) func(http.Handler) http.Handler

func RateLimiterMiddleware

func RateLimiterMiddleware(rl types.IRateLimiter) types.Middleware

func SanitizationMiddleware

func SanitizationMiddleware() types.Middleware

Types

type CORSConfig

type CORSConfig struct {
	// contains filtered or unexported fields
}

func NewCORSConfig

func NewCORSConfig() *CORSConfig

func (*CORSConfig) AllowCredentials

func (c *CORSConfig) AllowCredentials() bool

func (*CORSConfig) AllowedHeaders

func (c *CORSConfig) AllowedHeaders() []string

func (*CORSConfig) AllowedMethods

func (c *CORSConfig) AllowedMethods() []string

func (*CORSConfig) AllowedOrigins

func (c *CORSConfig) AllowedOrigins() []string

func (*CORSConfig) SetAllowCredentials

func (c *CORSConfig) SetAllowCredentials(allow bool)

func (*CORSConfig) SetAllowedHeaders

func (c *CORSConfig) SetAllowedHeaders(headers []string)

func (*CORSConfig) SetAllowedMethods

func (c *CORSConfig) SetAllowedMethods(methods []string)

func (*CORSConfig) SetAllowedOrigins

func (c *CORSConfig) SetAllowedOrigins(origins []string)

type CsrfConfig

type CsrfConfig struct {
	// contains filtered or unexported fields
}

func NewCsrfConfig

func NewCsrfConfig() *CsrfConfig

NewCsrfConfig crea una nueva configuración con valores por defecto

func (*CsrfConfig) CookieDomain

func (c *CsrfConfig) CookieDomain() string

func (*CsrfConfig) CookieHTTPOnly

func (c *CsrfConfig) CookieHTTPOnly() bool

func (*CsrfConfig) CookieName

func (c *CsrfConfig) CookieName() string

func (*CsrfConfig) CookiePath

func (c *CsrfConfig) CookiePath() string

func (*CsrfConfig) CookieSameSite

func (c *CsrfConfig) CookieSameSite() csrf.SameSiteMode

func (*CsrfConfig) CookieSecure

func (c *CsrfConfig) CookieSecure() bool

func (*CsrfConfig) SecretKey

func (c *CsrfConfig) SecretKey() []byte

func (*CsrfConfig) SetCookieDomain

func (c *CsrfConfig) SetCookieDomain(domain string)

func (*CsrfConfig) SetCookieHTTPOnly

func (c *CsrfConfig) SetCookieHTTPOnly(httpOnly bool)

func (*CsrfConfig) SetCookieName

func (c *CsrfConfig) SetCookieName(name string)

func (*CsrfConfig) SetCookiePath

func (c *CsrfConfig) SetCookiePath(path string)

func (*CsrfConfig) SetCookieSameSite

func (c *CsrfConfig) SetCookieSameSite(sameSite csrf.SameSiteMode)

func (*CsrfConfig) SetCookieSecure

func (c *CsrfConfig) SetCookieSecure(secure bool)

func (*CsrfConfig) SetSecretKey

func (c *CsrfConfig) SetSecretKey(key []byte)

func (*CsrfConfig) SetTokenLookup

func (c *CsrfConfig) SetTokenLookup(lookup string)

func (*CsrfConfig) TokenLookup

func (c *CsrfConfig) TokenLookup() string

type JWTConfig

type JWTConfig struct {
	// contains filtered or unexported fields
}

func NewJWTConfig

func NewJWTConfig() *JWTConfig

func (*JWTConfig) Algorithms

func (j *JWTConfig) Algorithms() []string

func (*JWTConfig) Audience

func (j *JWTConfig) Audience() []string

func (*JWTConfig) Issuer

func (j *JWTConfig) Issuer() []string

func (*JWTConfig) Key

func (j *JWTConfig) Key() []byte

func (*JWTConfig) SetAlgorithms

func (j *JWTConfig) SetAlgorithms(algorithms []string)

func (*JWTConfig) SetAudience

func (j *JWTConfig) SetAudience(audience []string)

func (*JWTConfig) SetIssuer

func (j *JWTConfig) SetIssuer(issuer []string)

func (*JWTConfig) SetKey

func (j *JWTConfig) SetKey(key string)

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter() *RateLimiter

func (*RateLimiter) CleanupExpired

func (rl *RateLimiter) CleanupExpired()

func (*RateLimiter) MaxRequests

func (rl *RateLimiter) MaxRequests() int

func (*RateLimiter) Mu

func (rl *RateLimiter) Mu() *sync.Mutex

func (*RateLimiter) Requests

func (rl *RateLimiter) Requests() map[string]types.IRateRecord

func (*RateLimiter) SetMaxRequests

func (rl *RateLimiter) SetMaxRequests(maxRequests int)

func (*RateLimiter) SetWindow

func (rl *RateLimiter) SetWindow(window time.Duration)

func (*RateLimiter) Window

func (rl *RateLimiter) Window() time.Duration

type RateRecord

type RateRecord struct {
	// contains filtered or unexported fields
}

func (*RateRecord) Count

func (rr *RateRecord) Count() int

func (*RateRecord) Increment

func (r *RateRecord) Increment()

func (*RateRecord) ResetTime

func (rr *RateRecord) ResetTime() time.Time

Jump to

Keyboard shortcuts

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