gzip

package
v0.2.57 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package gzip provides pre-compressed data container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

MarshalJSON encodes Go value as JSON and compresses result with gzip.

func UnmarshalJSON

func UnmarshalJSON(data []byte, v interface{}) error

UnmarshalJSON decodes compressed JSON bytes into a Go value.

func WriteCompressedBytes

func WriteCompressedBytes(compressed []byte, w io.Writer) (int, error)

WriteCompressedBytes writes compressed bytes to response.

Bytes are unpacked if response writer does not support direct gzip writing.

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 compressed bytes.

func (JSONContainer) GzipCompressedJSON

func (jc JSONContainer) GzipCompressedJSON() []byte

GzipCompressedJSON returns JSON compressed with gzip.

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.

type Writer

type Writer interface {
	GzipWrite([]byte) (int, error)
}

Writer writes gzip data into suitable stream or returns 0, nil.

Jump to

Keyboard shortcuts

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