Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Brotli ¶
func Brotli(level Level) gin.HandlerFunc
Brotli provides a backward-compatible constructor using default options. It returns a middleware that applies Brotli response compression when clients advertise support.
func BrotliWith ¶
func BrotliWith(level Level, o Options) gin.HandlerFunc
BrotliWith returns the middleware configured with the fluent Options builder.
Types ¶
type BrotliEncoder ¶
BrotliEncoder is the minimal interface implemented by a Brotli encoder used by this package. It is deliberately small to allow plugging in fakes/mocks in tests and to decouple from the concrete implementation.
type Level ¶
type Level int
Level represents abstract compression levels similar to gzip/zstd middleware. They are mapped to brotli quality settings.
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 brotli middleware. Use NewOptions() to construct an instance and pass it to BrotliWith.