middlewares

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package middlewares provides HTTP middleware for the Gate server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChiRouteLabeler added in v1.0.4

func ChiRouteLabeler(next http.Handler) http.Handler

ChiRouteLabeler attaches the matched chi route pattern as the "http.route" attribute on the active otelhttp span. It must run after otelhttp.NewMiddleware so the labeler is present in the request context.

func OriginVerify

func OriginVerify(cfg config.OriginConfig) func(http.Handler) http.Handler

OriginVerify creates middleware that validates requests contain a shared secret header. Uses constant-time comparison to prevent timing attacks.

When origin verification is disabled via config, the middleware is a no-op. Returns 403 Forbidden when the header is missing or the value doesn't match.

func SecurityHeaders

func SecurityHeaders(next http.Handler) http.Handler

SecurityHeaders adds OWASP-recommended security headers to responses. HSTS header is only added when the request is served over TLS.

Types

This section is empty.

Jump to

Keyboard shortcuts

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