Documentation
¶
Index ¶
Constants ¶
const ( BestSpeed = brotli.BestSpeed BestCompression = brotli.BestCompression DefaultCompression = brotli.DefaultCompression DefalutContentLen = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonRequestFilter ¶
type CommonRequestFilter struct{}
CommonRequestFilter judge via common easy criteria like http method, accept-encoding header, etc.
func NewCommonRequestFilter ¶
func NewCommonRequestFilter() *CommonRequestFilter
NewCommonRequestFilter ...
func (*CommonRequestFilter) ShouldCompress ¶
func (c *CommonRequestFilter) ShouldCompress(req *http.Request) bool
ShouldCompress implements RequestFilter interface
type Config ¶
type Config struct { // 压缩等级 CompressionLevel int // 响应内容长度 MinContentLength int64 // 根据请求校验是否过滤 RequestFilter []RequestFilter // 根据响应校验是否过滤 ResponseHeaderFilter []ResponseHeaderFilter }
Config is used in Handler initialization
type ContentTypeFilter ¶
type ContentTypeFilter struct {
// contains filtered or unexported fields
}
ContentTypeFilter
func DefaultContentTypeFilter ¶
func DefaultContentTypeFilter() *ContentTypeFilter
DefaultContentTypeFilter
func NewContentTypeFilter ¶
func NewContentTypeFilter(types []string) *ContentTypeFilter
NewContentTypeFilter ...
func (*ContentTypeFilter) ShouldCompress ¶
func (e *ContentTypeFilter) ShouldCompress(header http.Header) bool
ShouldCompress implements RequestFilter interface
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implement brotli compression for gin
func NewHandler ¶
type RequestApiFilter ¶
type RequestApiFilter struct {
// contains filtered or unexported fields
}
func NewRequestApiFilter ¶
func NewRequestApiFilter(path []string) *RequestApiFilter
func (*RequestApiFilter) ShouldCompress ¶
func (r *RequestApiFilter) ShouldCompress(req *http.Request) bool
type RequestFilter ¶
Request filter conditions
type ResponseHeaderFilter ¶
Response filter conditions
type SkipCompressedFilter ¶
type SkipCompressedFilter struct{}
SkipCompressedFilter judges whether content has been already compressed
func NewSkipCompressedFilter ¶
func NewSkipCompressedFilter() *SkipCompressedFilter
NewSkipCompressedFilter ...
func (*SkipCompressedFilter) ShouldCompress ¶
func (s *SkipCompressedFilter) ShouldCompress(header http.Header) bool
ShouldCompress implements ResponseHeaderFilter interface
Content-Encoding: https://tools.ietf.org/html/rfc2616#section-3.5