Documentation
¶
Index ¶
- Constants
- func Middleware(options ...Options) macaron.Handler
- type Options
- type ProxyResponseWriter
- func (proxy *ProxyResponseWriter) Before(before macaron.BeforeFunc)
- func (proxy *ProxyResponseWriter) Close() error
- func (proxy *ProxyResponseWriter) Flush()
- func (proxy *ProxyResponseWriter) Header() http.Header
- func (proxy *ProxyResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (proxy *ProxyResponseWriter) Size() int
- func (proxy *ProxyResponseWriter) Status() int
- func (proxy *ProxyResponseWriter) Write(b []byte) (int, error)
- func (proxy *ProxyResponseWriter) WriteHeader(code int)
- func (proxy *ProxyResponseWriter) Written() bool
- type WriterPool
Constants ¶
const (
// MinSize is the minimum size of content we will compress
MinSize = 1400
)
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
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 {
// contains filtered or unexported fields
}
ProxyResponseWriter is a wrapped macaron ResponseWriter that may compress its contents
func (*ProxyResponseWriter) Before ¶ added in v1.10.1
func (proxy *ProxyResponseWriter) Before(before macaron.BeforeFunc)
Before allows for a function to be called before the ResponseWriter has been written to. This is useful for setting headers or any other operations that must happen before a response has been written.
func (*ProxyResponseWriter) Close ¶
func (proxy *ProxyResponseWriter) Close() error
Close the writer
func (*ProxyResponseWriter) Header ¶ added in v1.10.1
func (proxy *ProxyResponseWriter) Header() http.Header
Header returns the header map
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) Size ¶ added in v1.10.1
func (proxy *ProxyResponseWriter) Size() int
Size returns the size of the response body.
func (*ProxyResponseWriter) Status ¶ added in v1.10.1
func (proxy *ProxyResponseWriter) Status() int
Status returns the status code of the response or 0 if the response has not been written.
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
func (*ProxyResponseWriter) Written ¶ added in v1.10.1
func (proxy *ProxyResponseWriter) Written() bool
Written returns whether or not the ResponseWriter has been written.
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 ¶
func (wp *WriterPool) Get(rw macaron.ResponseWriter) *gzip.Writer
Get a writer from the pool - or create one if not available