middlewares

package
v0.0.0-...-98ab9ba Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHandler

type AppHandler func(request *request.Request) responses.Response

type CacheMiddleware

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

func NewCacheMiddleware

func NewCacheMiddleware(expiration time.Duration, keyPrefix string) *CacheMiddleware

func (*CacheMiddleware) Apply

func (cm *CacheMiddleware) Apply(next AppHandler) AppHandler

type IPFilterMiddleware

type IPFilterMiddleware struct {
	AllowedIPs []string
}

func (IPFilterMiddleware) Apply

func (ipm IPFilterMiddleware) Apply(next AppHandler) AppHandler

type LoggingMiddleware

type LoggingMiddleware struct{}

func (LoggingMiddleware) Apply

type Middleware

type Middleware interface {
	Apply(AppHandler) AppHandler
}

func NewCORSMiddleware

func NewCORSMiddleware(allowedOrigins, allowedMethods, allowedHeaders []string) Middleware

Creates a new CORS middleware that allows requests from any origin (using the * character) and with the specified HTTP methods and headers.

type RateLimiterMiddleware

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

func NewRateLimiterMiddleware

func NewRateLimiterMiddleware(maxRequests int, interval time.Duration) *RateLimiterMiddleware

Create in-memory rate limiter The limiter is limiting IP to make more then maxRequests in the interval duration.

func (*RateLimiterMiddleware) Apply

func (rlm *RateLimiterMiddleware) Apply(next AppHandler) AppHandler

type TimeoutMiddleware

type TimeoutMiddleware struct {
	Timeout time.Duration
}

func (TimeoutMiddleware) Apply

func (tm TimeoutMiddleware) Apply(next AppHandler) AppHandler

type TimingMiddleware

type TimingMiddleware struct{}

func (TimingMiddleware) Apply

Jump to

Keyboard shortcuts

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