middleware

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gzip

func Gzip(gzipCfg ...*GzipConfig) harmony.MiddlewareFunc

Gzip returns a middleware which compresses HTTP response using gzip compression

func Logger

func Logger(loggerCfg ...*LoggerConfig) harmony.MiddlewareFunc

Logger returns a middleware which logs HTTP requests.

Types

type GzipConfig

type GzipConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper Skipper

	// Gzip compression level.
	// Optional. Default value -1.
	// -2 means use Huffman-only compression.
	// -1 means use default compression level.
	// 1 (BestSpeed) to 9 (BestCompression).
	Level int

	// MinLength is the minimum length required for compression.
	// Optional. Default value 0.
	MinLength int
}

GzipConfig defines the config for Gzip middleware.

type LoggerConfig

type LoggerConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper Skipper

	// Format defines the logging format with defined variables.
	// Optional. Default value {remote_ip} - {host} "{method} {path} {protocol}" {status} {latency}
	// possible variables:
	// - {remote_ip}
	// - {host}
	// - {method}
	// - {path}
	// - {protocol}
	// - {status}
	// - {latency}
	Format string
}

LoggerConfig defines the config for Logger middleware.

type Skipper

type Skipper func(ctx harmony.Context) bool

Skipper defines a function to skip middleware.

Jump to

Keyboard shortcuts

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