Documentation
¶
Overview ¶
package crww holds the main logic to wrap the ResponseWriter. For ease of use, look on the adapter package. The example subdir has a working static server wrapped with CRWW using the adapter package
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //Initial plan for methods and their functions //As this var is public, you may want to add (or remove) custom encoders Methods = []CompressorSpec{ { Name: "br", Fn: br.Compress, }, { Name: "zstd", Fn: zstd.Compress, }, { Name: "gzip", Fn: gz.Compress, }, } )
Functions ¶
This section is empty.
Types ¶
type CRWW ¶
type CRWW struct {
// contains filtered or unexported fields
}
func NewCRWW ¶
func NewCRWW(wrap http.ResponseWriter, req *http.Request) *CRWW
Wrap a ResponseWriter. Original one must **not** be used after passed to this function. Also the req is needed to find a suitable compression method. Keep in mind you must call Close in order to end sending response
func (*CRWW) Close ¶
Close function must be called in order to flush written response and close everything Close will block until all buffer data is consumed and sent to the original ResponseWriter.
func (*CRWW) Header ¶
Goes directly to the original ResponseWriter. You shall not touch the Content-Encoding header unless you like garbage.
func (*CRWW) Write ¶
Implements io.Writer. Write operations are buffered so it won't block unless buffer size is exhausted.
func (*CRWW) WriteHeader ¶
Directly sent to original ResponseWriter
type CompressorFunc ¶
CompressorFunc reads from inReader and writes encoded data to writeTo writer This func will be called in a separate goroutine Function should panic if internal error occurred. Must call done function when finished writing output
func DetectCompression ¶
func DetectCompression(accept string) (encoding string, compressor CompressorFunc)
Detect accepted formats and use the best compression method supported If encoding=="" then compressor==nil and no compression is supported/matched
type CompressorSpec ¶
type CompressorSpec struct {
//Name must match the name for the given method on Content-Encoding and Accept-Encoding options
Name string
//Function to use the compressor
Fn CompressorFunc
}
Spec for compression method
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapter contains structures to receive http requests (from net/http package) and wrap their ResponseWriter before calling the next-hop.
|
Package adapter contains structures to receive http requests (from net/http package) and wrap their ResponseWriter before calling the next-hop. |
|
This package holds a living example of working with CRWW using the adapter package.
|
This package holds a living example of working with CRWW using the adapter package. |