middleware

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

/Users/sookh.com/go/pkg/mod/github.com/!jubaer!hossain/rootx@v1.4.7/pkg/core/middleware/limiterMidleware.go

Index

Constants

View Source
const (
	ClaimsKey key = iota
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(next http.Handler) http.Handler

AuthMiddleware validates JWT tokens and protects routes

func CorsMiddleware added in v1.4.4

func CorsMiddleware(next http.Handler) http.Handler

CORSMiddleware is a middleware function that adds CORS headers to HTTP responses.

func GetClaimsFromContext

func GetClaimsFromContext(ctx context.Context) (jwt.MapClaims, bool)

GetClaimsFromContext retrieves claims from request context

func LimiterMiddleware

func LimiterMiddleware(next http.Handler) http.Handler

LimiterMiddleware creates a new rate limiting middleware

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func PrometheusMiddleware

func PrometheusMiddleware(next http.Handler, requestsTotal *prometheus.CounterVec, requestDuration *prometheus.HistogramVec) http.Handler

PrometheusMiddleware is a middleware for recording Prometheus metrics.

func SecurityHeadersMiddleware added in v1.4.4

func SecurityHeadersMiddleware(next http.Handler) http.Handler

SecurityHeadersMiddleware adds security headers to the response

Types

type RateLimitConfig added in v1.4.8

type RateLimitConfig struct {
	Enabled      bool
	Limit        int
	Duration     time.Duration
	WhitelistIPs []string
	BlacklistIPs []string
}

RateLimitConfig holds the configuration for rate limiting

Jump to

Keyboard shortcuts

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