encode

package
v2.0.0-...-4d08927 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package encode implements an encoder middleware for Caddy. The initial enhancements related to Accept-Encoding, minimum content length, and buffer/writer pools were adapted from https://github.com/xi2/httpgzip then modified heavily to accommodate modular encoders and fix bugs. Code borrowed from that repository is Copyright (c) 2015 The Httpgzip Authors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encode

type Encode struct {
	// Selection of compression algorithms to choose from. The best one
	// will be chosen based on the client's Accept-Encoding header.
	EncodingsRaw caddy.ModuleMap `json:"encodings,omitempty" caddy:"namespace=http.encoders"`

	// Only encode responses that are at least this many bytes long.
	MinLength int `json:"minimum_length,omitempty"`
	// contains filtered or unexported fields
}

Encode is a middleware which can encode responses.

func (Encode) CaddyModule

func (Encode) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*Encode) Provision

func (enc *Encode) Provision(ctx caddy.Context) error

Provision provisions enc.

func (*Encode) ServeHTTP

func (enc *Encode) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*Encode) UnmarshalCaddyfile

func (enc *Encode) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens. Syntax:

encode [<matcher>] <formats...> {
    gzip [<level>]
    zstd
}

Specifying the formats on the first line will use those formats' defaults.

type Encoder

type Encoder interface {
	io.WriteCloser
	Reset(io.Writer)
}

Encoder is a type which can encode a stream of data.

type Encoding

type Encoding interface {
	AcceptEncoding() string
	NewEncoder() Encoder
}

Encoding is a type which can create encoders of its kind and return the name used in the Accept-Encoding header.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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