providers

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Zstandard Provider = 1 << iota
	Brotli                 // 2
	GZip                   // 4
	Deflate                // 8
	Identity  Provider = 0 // no encoding
	// capacity for 3 more encoding types @ 16, 32, 64
	//
	// browsers don't currently support snappy, so it is isolated to ensure a full
	// bifurcation of web vs. general encoders, as more providers are added later
	Snappy Provider = 128

	// for use in headers
	ZstandardValue = "zstd"
	BrotliValue    = "br"
	GZipValue      = "gzip"
	DeflateValue   = "deflate"
	SnappyValue    = "snappy"
	// might be used in configs
	ZstandardAltValue = "zstandard"
	BrotliAltValue    = "brotli"
)

Variables

View Source
var (
	AllSupportedWebProviders       string
	AllSupportedWebProvidersBitmap Provider
)

these are populated in init based on maxWebProvider, providerVals, and providerValLookup

Functions

func Providers

func Providers() []string

Providers returns the list of encodings that are known to be decodable in a web browser

func WebProviders

func WebProviders() []string

WebProviders returns the list of encodings that are known to be decodable by web browsers. This can be overlapped with the client's accepted encodings to determine which supported encodings can be applied to the ResponseWriter

Types

type DecoderInitializer

type DecoderInitializer func(io.Reader) reader.ReadCloserResetter

func GetDecoderInitializer

func GetDecoderInitializer(provider string) DecoderInitializer

GetDecoderInitializer returns a DecoderInitializer - one that can be passed an io.ReadCloser to get a decoder Reader for the passed Reader

func SelectDecoderInitializer

func SelectDecoderInitializer(p Provider) DecoderInitializer

SelectEncoderInitializer returns an EncoderInitializer based on the provided providers bitmap

type EncoderInitializer

type EncoderInitializer func(io.Writer, int) io.WriteCloser

func GetEncoderInitializer

func GetEncoderInitializer(provider string) (EncoderInitializer, string)

GetEncoderInitializer returns an EncoderInitializer - one that can be passed an io.Writer to get an encoder wrapper for the passed writer, as well as an encoding value that is compatible with Content-Encoding headers

func SelectEncoderInitializer

func SelectEncoderInitializer(p Provider) (EncoderInitializer, string)

SelectEncoderInitializer returns an EncoderInitializer based on the provided providers bitmap

type Lookup

type Lookup map[string]Provider

func (Lookup) Clone

func (l Lookup) Clone() Lookup

Clone returns a perfect copy of the lookup

type Provider

type Provider byte

func GetCompatibleWebProviders

func GetCompatibleWebProviders(acceptedEncodings string) (string, Provider)

GetCompatibleWebProviders returns the string and the bitmap of the compatible providers negotiated between Trickster and the Client. The string representation is compatible with the Accept-Encoding header

func ProviderID

func ProviderID(providerName string) Provider

ProviderID returns the byte value of the provided encoding provider name

func (Provider) String

func (p Provider) String() string

type ReverseLookup

type ReverseLookup map[Provider]string

Jump to

Keyboard shortcuts

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