middleware

package
v0.0.0-...-50bae67 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSecurityHeaders

func AddSecurityHeaders(w http.ResponseWriter)

func ClientAcceptsGzip

func ClientAcceptsGzip(r *http.Request) bool

ClientAcceptsGzip checks request headers for gzip support

func GzipGinMiddleware

func GzipGinMiddleware(c *gin.Context)

GzipGinMiddleware writes gzipped response for gin context; it assumes caller checked ShouldGzip and Accept-Encoding

func GzipMiddleware

func GzipMiddleware(next http.Handler) http.Handler

func RateLimitMiddleware

func RateLimitMiddleware() gin.HandlerFunc

RateLimitMiddleware enforces per-IP throttling with escalating bans.

func SetHSTS

func SetHSTS(w http.ResponseWriter)

SetHSTS sets the Strict-Transport-Security header for HTTPS responses. Should only be called when the server is serving over HTTPS.

func ShouldGzip

func ShouldGzip(path string) bool

Types

type BanRecord

type BanRecord struct {
	IP       string
	Start    time.Time
	Duration time.Duration
	Reason   string
}

func BanHistory

func BanHistory() []BanRecord

BanHistory exposes recent ban events kept in memory for observability.

type GzipResponseWriter

type GzipResponseWriter struct {
	io.Writer
	gin.ResponseWriter
}

func (*GzipResponseWriter) Write

func (w *GzipResponseWriter) Write(b []byte) (int, error)

func (*GzipResponseWriter) WriteString

func (w *GzipResponseWriter) WriteString(s string) (int, error)

type HTTPGzipResponseWriter

type HTTPGzipResponseWriter struct {
	io.Writer
	http.ResponseWriter
}

HTTPGzipResponseWriter is used for net/http handlers

func (*HTTPGzipResponseWriter) Write

func (w *HTTPGzipResponseWriter) Write(b []byte) (int, error)

type RateLimiter

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

Jump to

Keyboard shortcuts

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