middleware

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 18 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(realm string, credentials map[string]string) zoox.Middleware

BasicAuth is a middleware that authenticates via Basic Auth.

func CORS added in v1.0.20

func CORS(cfg ...*CorsConfig) zoox.Middleware

CORS is a middleware for handling CORS (Cross-Origin Resource Sharing)

func Gzip added in v1.3.0

func Gzip(cfg ...*GzipConfig) zoox.Middleware

Gzip is a gzip moddleware for zoox.

func HealthCheck

func HealthCheck() zoox.Middleware

HealthCheck is a middleware that checks the health of the application.

func Jwt added in v1.0.25

func Jwt(secret string, algorithm ...string) zoox.Middleware

Jwt is a middleware that authenticates via JWT.

func Logger

func Logger() zoox.Middleware

Logger is a middleware that logs the request as it goes through the handler.

func Proxy added in v1.2.9

func Proxy(cfg *ProxyConfig) zoox.Middleware

Proxy is a middleware that authenticates via Basic Auth.

func RateLimit added in v1.2.17

func RateLimit(cfg *RateLimitConfig) zoox.Middleware

RateLimit middleware for zoox

func RealIP

func RealIP() zoox.Middleware

RealIP is a middleware that adds a "X-Real-IP" header to the request.

func Recovery

func Recovery() zoox.Middleware

Recovery is the recovery middleware

func RequestID added in v1.1.2

func RequestID() zoox.Middleware

RequestID is a middleware that adds a request ID to the context.

func Rewrite added in v1.0.20

func Rewrite(cfg ...*RewriteConfig) zoox.Middleware

Rewrite is a middleware that rewrites the request path.

func Timeout

func Timeout(timeout time.Duration) zoox.Middleware

Timeout is a middleware that sets a timeout for the request.

Types

type CorsConfig added in v1.0.20

type CorsConfig struct {
	IgnoreFunc       func(ctx *zoox.Context) bool
	AllowOrigins     []string
	AllowOriginFunc  func(origin string) bool
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials bool
	ExposeHeaders    []string
}

CorsConfig is the configuration for the CORS middleware.

func DefaultCorsConfig added in v1.0.20

func DefaultCorsConfig() *CorsConfig

DefaultCorsConfig is the default CORS configuration.

type GzipConfig added in v1.3.0

type GzipConfig struct {
	Level int
	// Options  gzip.Options
	OptionFn gzip.Option
}

GzipConfig is the configuration for gzip middleware.

type ProxyConfig added in v1.2.9

type ProxyConfig struct {
	Rewrites map[string]ProxyRewrite
}

ProxyConfig is the config of proxy middlewares

type ProxyRewrite added in v1.2.9

type ProxyRewrite struct {
	Target   string
	Rewrites map[string]string
}

ProxyRewrite ...

type RateLimitConfig added in v1.2.17

type RateLimitConfig struct {
	Period time.Duration
	Limit  int64
	//
	Namespace string
	//
	RedisHost     string
	RedisPort     int
	RedisDB       int
	RedisPassword string
}

RateLimitConfig ...

type RewriteConfig added in v1.0.20

type RewriteConfig struct {
	Rewrites map[string]string
}

RewriteConfig is the configuration for the Rewrite middleware.

Jump to

Keyboard shortcuts

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