Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Zstd ¶
func Zstd(level Level) gin.HandlerFunc
Zstd provides a backward-compatible constructor using default options. It returns a middleware that applies Zstandard response compression when clients advertise support.
Types ¶
type Level ¶
type Level int
Level represents abstract compression levels similar to gzip middleware. They are mapped to klauspost/compress zstd encoder options.
type Options ¶
type Options interface {
// WithMinLength sets the minimum content length (in bytes) for compression and returns the updated Options instance.
WithMinLength(n int) Options
// WithSkipper sets a custom function to determine whether a request should skip compression and returns the updated Options.
WithSkipper(f func(*gin.Context) bool) Options
// WithExcludeExtensions adds specified file extensions to the exclusion list, skipping compression for matching requests.
WithExcludeExtensions(exts ...string) Options
// WithExcludePaths adds the specified paths to the exclusion list, skipping compression for requests matching these paths.
WithExcludePaths(paths ...string) Options
// contains filtered or unexported methods
}
Options defines a fluent builder interface for configuring the zstd middleware. Use NewOptions() to construct an instance and pass it to ZstdWith.
type ZstdEncoder ¶
ZstdEncoder is the minimal interface implemented by a Zstandard encoder used by this package. It is deliberately small to allow plugging in fakes/mocks in tests and to decouple from the concrete klauspost/compress implementation.