middleware

package
v0.10.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEventMetadataToCtx added in v0.7.0

func AddEventMetadataToCtx(next http.Handler) http.Handler

func AddOrgIDToCtx added in v0.9.0

func AddOrgIDToCtx(resolver resolvers.Resolver, extractor OrgIDExtractor) func(http.Handler) http.Handler

AddOrgIDToCtx extracts organization ID using the supplied extractor, validates it using the provided resolver, and injects it into the request context.

func CreateRouteExistsMiddleware added in v0.6.0

func CreateRouteExistsMiddleware(router chi.Router) func(http.Handler) http.Handler

func GrpcAuthMiddleware

func GrpcAuthMiddleware(ctx context.Context) (context.Context, error)

client has to present client TLS certificate

func InstallRateLimiter added in v0.9.0

func InstallRateLimiter(r chi.Router, opts RateLimitOptions)

InstallRateLimiter installs RealIP + custom rate limiter.

func NewHTTPServer

func NewHTTPServer(router http.Handler, log logrus.FieldLogger, address string, cfg *config.Config) *http.Server

func NewHTTPServerWithTLSContext

func NewHTTPServerWithTLSContext(router http.Handler, log logrus.FieldLogger, address string, cfg *config.Config) *http.Server

func NewTLSListener

func NewTLSListener(address string, tlsConfig *tls.Config) (net.Listener, error)

NewTLSListener returns a new TLS listener. If the address is empty, it will listen on localhost's next available port.

func RequestID added in v0.6.0

func RequestID(next http.Handler) http.Handler

func RequestSizeLimiter added in v0.4.0

func RequestSizeLimiter(maxURLLength int, maxNumHeaders int) func(http.Handler) http.Handler

RequestSizeLimiter returns a middleware that limits the URL length and the number of request headers.

func TrustedRealIP added in v0.9.0

func TrustedRealIP(trustedCIDRs []string) func(http.Handler) http.Handler

TrustedRealIP only rewrites RemoteAddr when the immediate peer is in one of your LB CIDRs

func ValidateClientTlsCert

func ValidateClientTlsCert(ctx context.Context) (context.Context, error)

Types

type OrgIDExtractor added in v0.10.0

type OrgIDExtractor func(*http.Request) (uuid.UUID, error)

OrgIDExtractor extracts an organization ID from an HTTP request.

var CertOrgIDExtractor OrgIDExtractor = extractOrgIDFromRequestCert

CertOrgIDExtractor reads the org_id from the client certificate.

var QueryOrgIDExtractor OrgIDExtractor = extractOrgIDFromRequestQuery

QueryOrgIDExtractor is the default extractor that reads the org_id from the query string.

type RateLimitOptions added in v0.9.0

type RateLimitOptions struct {
	Requests       int
	Window         time.Duration
	Message        string
	TrustedProxies []string
}

RateLimitOptions configures rate limiting behavior

Jump to

Keyboard shortcuts

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