middleware

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware added in v0.3.13

func CORSMiddleware(allowedOrigins []string) func(http.Handler) http.Handler

CORSMiddleware returns a CORS middleware handler. If allowedOrigins is empty, the returned middleware is a no-op, making CORS effectively disabled. This is the secure default: deployments that do not explicitly configure allowed origins will not accept cross-origin requests.

func DeprecationMiddleware added in v0.3.18

func DeprecationMiddleware(cfg DeprecationConfig) func(http.Handler) http.Handler

DeprecationMiddleware injects RFC 8594 deprecation headers (Deprecation, Sunset, Link) on responses to requests under any configured deprecated prefix, and logs a warning at most once per minute. Requests to any other path pass through unchanged.

func ValidationMiddleware

func ValidationMiddleware(next http.Handler) http.Handler

ValidationMiddleware validates all query parameters and request body for unsafe characters

func WrapWithValidation

func WrapWithValidation(handler http.Handler) http.Handler

WrapWithValidation wraps an http.Handler with custom validation middleware

Types

type DeprecatedPath added in v0.3.18

type DeprecatedPath struct {
	// Prefix is matched against the request path.
	Prefix string
	// Successor is advertised in the Link header with rel="successor-version".
	Successor string
}

DeprecatedPath pairs a deprecated API path prefix with the prefix of the version that replaces it. Both should end with a slash, for example "/api/model_registry/v1alpha3/" and "/api/model_registry/v1/".

type DeprecationConfig added in v0.3.18

type DeprecationConfig struct {
	// SunsetDate is the date after which the deprecated APIs may be removed.
	SunsetDate time.Time
	// Paths lists the deprecated prefixes and their successors.
	Paths []DeprecatedPath
}

DeprecationConfig configures the deprecation middleware.

Jump to

Keyboard shortcuts

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