Documentation
¶
Index ¶
- func CORSMiddleware(allowedOrigins []string) func(http.Handler) http.Handler
- func DeprecationMiddleware(cfg DeprecationConfig) func(http.Handler) http.Handler
- func ValidationMiddleware(next http.Handler) http.Handler
- func WrapWithValidation(handler http.Handler) http.Handler
- type DeprecatedPath
- type DeprecationConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶ added in v0.3.13
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 ¶
ValidationMiddleware validates all query parameters and request body for unsafe characters
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.