middleware

package
v0.0.0-...-cdbd8f0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chain

func Chain(middleware ...Middleware) http.Handler

Types

type Adapter

type Adapter struct {
	Request         *http.Request
	ResponseWriter  http.ResponseWriter
	Logger          *slog.Logger
	DB              *sql.DB
	Ctx             context.Context
	Cancel          context.CancelFunc
	ErrorInResponse bool
	LogDBQueries    bool
	// contains filtered or unexported fields
}

func Init

func Init(logger *slog.Logger, db *sql.DB, errorInResponse bool, logDBQueries bool, ipRateLimit rate.Limit, burst int) *Adapter

func (*Adapter) HTTPToContextHandler

func (a *Adapter) HTTPToContextHandler(h func(*Adapter) error) http.HandlerFunc

Create an adapter function

type IPRateLimiter

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

1. Simple rate limiter per IP

func NewIPRateLimiter

func NewIPRateLimiter(r rate.Limit, b int) *IPRateLimiter

type Middleware

type Middleware func(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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