middleware

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPContentDecompressor

func HTTPContentDecompressor(h http.Handler, opts ...DecompressorOption) http.Handler

HTTPContentDecompressor is a middleware that offloads the task of handling compressed HTTP requests by identifying the compression format in the "Content-Encoding" header and re-writing request body so that the handlers further in the chain can work on decompressed data. It supports gzip and deflate/zlib compression.

Types

type CompressRoundTripper added in v0.21.0

type CompressRoundTripper struct {
	RoundTripper http.RoundTripper
	// contains filtered or unexported fields
}

func NewCompressRoundTripper added in v0.21.0

func NewCompressRoundTripper(rt http.RoundTripper, compressionType CompressionType) *CompressRoundTripper

func (*CompressRoundTripper) CompressionType added in v0.42.0

func (r *CompressRoundTripper) CompressionType() CompressionType

func (*CompressRoundTripper) RoundTrip added in v0.21.0

func (r *CompressRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type CompressionType added in v0.42.0

type CompressionType string
const (
	CompressionGzip    CompressionType = "gzip"
	CompressionZlib    CompressionType = "zlib"
	CompressionDeflate CompressionType = "deflate"
	CompressionSnappy  CompressionType = "snappy"
	CompressionZstd    CompressionType = "zstd"
	CompressionNone    CompressionType = "none"
	CompressionEmpty   CompressionType = ""
)

func (*CompressionType) UnmarshalText added in v0.42.0

func (ct *CompressionType) UnmarshalText(in []byte) error

type DecompressorOption

type DecompressorOption func(d *decompressor)

func WithErrorHandler

func WithErrorHandler(e ErrorHandler) DecompressorOption

type ErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int)

type WrappedServerStream added in v0.41.0

type WrappedServerStream struct {
	grpc.ServerStream
	// WrappedContext is the wrapper's own Context. You can assign it.
	WrappedContext context.Context
}

WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.

func WrapServerStream added in v0.41.0

func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream

WrapServerStream returns a ServerStream that has the ability to overwrite context.

func (*WrappedServerStream) Context added in v0.41.0

func (w *WrappedServerStream) Context() context.Context

Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()

Jump to

Keyboard shortcuts

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