Documentation
¶
Index ¶
- func AddSecurityHeaders(w http.ResponseWriter)
- func ClientAcceptsGzip(r *http.Request) bool
- func GzipGinMiddleware(c *gin.Context)
- func GzipMiddleware(next http.Handler) http.Handler
- func RateLimitMiddleware() gin.HandlerFunc
- func SetHSTS(w http.ResponseWriter)
- func ShouldGzip(path string) bool
- type BanRecord
- type GzipResponseWriter
- type HTTPGzipResponseWriter
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSecurityHeaders ¶
func AddSecurityHeaders(w http.ResponseWriter)
func ClientAcceptsGzip ¶
ClientAcceptsGzip checks request headers for gzip support
func GzipGinMiddleware ¶
GzipGinMiddleware writes gzipped response for gin context; it assumes caller checked ShouldGzip and Accept-Encoding
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 ¶
Types ¶
type BanRecord ¶
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) 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
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.