Documentation
¶
Index ¶
Constants ¶
View Source
const ( UseBrotli = "br" UseGzip = "gzip" UseDeflate = "deflate" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(option Option) gin.HandlerFunc
New a compress middleware, will use Option to config
Types ¶
type DeflateOption ¶ added in v1.1.0
type Option ¶ added in v1.1.0
type Option struct {
EnableMethods []string // enabled compress methods, will be matched in order
GzipLevel int
BrotliOption brotli.WriterOptions
DeflateOption DeflateOption
}
Option can enable and config each compress method for simple needs please use UseAllBestSpeed or UseAllBestBestCompression
func UseAllBestBestCompression ¶ added in v1.1.0
func UseAllBestBestCompression() Option
func UseAllBestSpeed ¶ added in v1.1.0
func UseAllBestSpeed() Option
type ResponseWriter ¶
type ResponseWriter struct {
gin.ResponseWriter
ComPressWriter io.WriteCloser
}
func NewBrotli ¶
func NewBrotli(writer gin.ResponseWriter, option Option) *ResponseWriter
func NewDeflate ¶
func NewDeflate(writer gin.ResponseWriter, option Option) *ResponseWriter
func NewGzip ¶
func NewGzip(writer gin.ResponseWriter, option Option) *ResponseWriter
func (*ResponseWriter) Close ¶
func (r *ResponseWriter) Close() error
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(statusCode int)
func (*ResponseWriter) WriteString ¶
func (r *ResponseWriter) WriteString(s string) (int, error)
Click to show internal directories.
Click to hide internal directories.