Documentation ¶
Index ¶
Constants ¶
View Source
const ( UseBrotli = "br" // br UseGzip = "gzip" // gzip UseDeflate = "deflate" // 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
DeflateOption is used to config deflate
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 HeadFilter map[string]string ExtensionsFilter []string PathFilter []string PathRegexFilter []string CustomFilter []func(c *gin.Context) bool // return true to exclude anything you want }
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
UseAllBestBestCompression will enable all compress methods with best compression
func UseAllBestSpeed ¶ added in v1.1.0
func UseAllBestSpeed() Option
UseAllBestSpeed will enable all compress methods with best speed
type ResponseWriter ¶
type ResponseWriter struct { gin.ResponseWriter ComPressWriter io.WriteCloser }
ResponseWriter is a generic response writer
func (*ResponseWriter) Write ¶
func (r *ResponseWriter) Write(data []byte) (int, error)
Write data to response
func (*ResponseWriter) WriteHeader ¶
func (r *ResponseWriter) WriteHeader(statusCode int)
WriteHeader writes the header
func (*ResponseWriter) WriteString ¶
func (r *ResponseWriter) WriteString(s string) (int, error)
WriteString writes string data to response
Click to show internal directories.
Click to hide internal directories.