gzip

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2019 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// MinSize is the minimum size of content we will compress
	MinSize = 1400
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(options ...Options) macaron.Handler

Middleware creates a macaron.Handler to proxy the response

Types

type Options

type Options struct {
	CompressionLevel int
}

Options represents the configuration for the gzip middleware

type ProxyResponseWriter

type ProxyResponseWriter struct {
	macaron.ResponseWriter
	// contains filtered or unexported fields
}

ProxyResponseWriter is a wrapped macaron ResponseWriter that may compress its contents

func (*ProxyResponseWriter) Close

func (proxy *ProxyResponseWriter) Close() error

Close the writer

func (*ProxyResponseWriter) Flush

func (proxy *ProxyResponseWriter) Flush()

Flush the writer

func (*ProxyResponseWriter) Hijack

func (proxy *ProxyResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

Hijack implements http.Hijacker. If the underlying ResponseWriter is a Hijacker, its Hijack method is returned. Otherwise an error is returned.

func (*ProxyResponseWriter) Write

func (proxy *ProxyResponseWriter) Write(b []byte) (int, error)

Write appends data to the proxied gzip writer.

func (*ProxyResponseWriter) WriteHeader

func (proxy *ProxyResponseWriter) WriteHeader(code int)

WriteHeader will ensure that we have setup the writer before we write the header

type WriterPool

type WriterPool struct {
	// contains filtered or unexported fields
}

WriterPool is a gzip writer pool to reduce workload on creation of gzip writers

func NewWriterPool

func NewWriterPool(compressionLevel int) *WriterPool

NewWriterPool creates a new pool

func (*WriterPool) Get

Get a writer from the pool - or create one if not available

func (*WriterPool) Put

func (wp *WriterPool) Put(w *gzip.Writer)

Put returns a writer to the pool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL