encodings

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	New() DecoderFunc
}

Decoder is simply a decoder factory that returns a new decoder func for every request (but only in case it is encoded)

type DecoderFunc

type DecoderFunc func(encoded []byte) (decoded []byte, err error)

DecoderFunc is a function that takes encoded byte-slice and returns decoded one

type Decoders

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

Decoders structure just encapsulates containing content decoders. This used for some http-compatibility actions like backward capability for compress and x-compress, gzip and x-gzip

func NewContentDecoders

func NewContentDecoders() Decoders

NewContentDecoders returns new instance of Decoders

func (Decoders) Acceptable

func (d Decoders) Acceptable() []string

Acceptable returns a string with all the available decoders, listed by comma. In case no decoders are presented, identity is used to notify a client that server does not accept any encodings

func (Decoders) Add

func (d Decoders) Add(token string, decoder Decoder)

Add simply adds a new decoder. In case gzip or compress is passed also x-gzip and x-compress keys will be automatically appended, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#directives

func (Decoders) AddDecoder

func (d Decoders) AddDecoder(token string, decoderFunc DecoderFunc)

AddDecoder does the same as Add except it adds directly decoderFunc. Left mostly in backward capability purposes

func (Decoders) Get

func (d Decoders) Get(token string) (decoder Decoder, found bool)

Get takes a string as an encoding token (name), returns corresponding Decoder

func (Decoders) GetDecoder

func (d Decoders) GetDecoder(token string) (decoder Decoder, found bool)

GetDecoder is an ordinary Get, still exists in backward-capability purposes

Jump to

Keyboard shortcuts

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