Documentation
¶
Overview ¶
Package gzip provides pre-compressed data container.
Index ¶
- func MarshalJSON(v interface{}) ([]byte, error)
- func UnmarshalJSON(data []byte, v interface{}) error
- func WriteCompressedBytes(compressed []byte, w io.Writer) (int, error)
- type JSONContainer
- func (jc JSONContainer) ETag() string
- func (jc JSONContainer) GzipCompressedJSON() []byte
- func (jc JSONContainer) GzipETag() string
- func (jc JSONContainer) JSONWriteTo(w io.Writer) (int, error)
- func (jc JSONContainer) MarshalJSON() (j []byte, err error)
- func (jc *JSONContainer) PackJSON(v interface{}) error
- func (jc JSONContainer) UnpackJSON(v interface{}) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSON ¶
MarshalJSON encodes Go value as JSON and compresses result with gzip.
func UnmarshalJSON ¶
UnmarshalJSON decodes compressed JSON bytes into a Go value.
Types ¶
type JSONContainer ¶
type JSONContainer struct {
// contains filtered or unexported fields
}
JSONContainer contains compressed JSON.
func (JSONContainer) ETag ¶
func (jc JSONContainer) ETag() string
ETag returns hash of uncompressed JSON content, identifying the identity representation.
Unlike hashing compressed bytes, this is stable across changes to the gzip/flate implementation (e.g. across Go versions), which do not guarantee stable output bytes for the same input.
func (JSONContainer) GzipCompressedJSON ¶
func (jc JSONContainer) GzipCompressedJSON() []byte
GzipCompressedJSON returns JSON compressed with gzip.
func (JSONContainer) GzipETag ¶ added in v0.2.76
func (jc JSONContainer) GzipETag() string
GzipETag returns a hash of uncompressed JSON content salted for the gzip-compressed representation, so it differs from ETag.
The gzip and identity representations are byte-distinct, so gzip-compression middleware (see response/gzip) uses this instead of ETag when serving the gzip body, to avoid one strong validator being shared between two different representations.
func (JSONContainer) JSONWriteTo ¶
func (jc JSONContainer) JSONWriteTo(w io.Writer) (int, error)
JSONWriteTo writes JSON payload to writer.
func (JSONContainer) MarshalJSON ¶
func (jc JSONContainer) MarshalJSON() (j []byte, err error)
MarshalJSON returns uncompressed JSON.
func (*JSONContainer) PackJSON ¶
func (jc *JSONContainer) PackJSON(v interface{}) error
PackJSON puts Go value in JSON container.
func (JSONContainer) UnpackJSON ¶
func (jc JSONContainer) UnpackJSON(v interface{}) error
UnpackJSON unmarshals data from JSON container into a Go value.