middleware

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(users []BasicAuthUser) func(next http.Handler) http.Handler

func CORS

func CORS(cfg AccessControlConfig) func(next http.Handler) http.Handler

func Recovery

func Recovery() func(http.Handler) http.Handler

Recovery creates a middleware that recovers from panics and returns a 500 error

func RecoveryWithHandler

func RecoveryWithHandler(handler func(w http.ResponseWriter, r *http.Request, err interface{})) func(http.Handler) http.Handler

RecoveryWithHandler creates a middleware with a custom error handler

func RecoveryWithLogger

func RecoveryWithLogger(logf func(format string, args ...interface{})) func(http.Handler) http.Handler

RecoveryWithLogger creates a middleware that logs panics using a custom logger

func Timeout

func Timeout(timeout time.Duration) func(next http.Handler) http.Handler

Types

type AccessControlConfig

type AccessControlConfig struct {
	AllowOrigin      string
	AllowCredentials bool
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	MaxAge           int
}

type BasicAuthUser

type BasicAuthUser struct {
	Name     string
	Password string
}

Jump to

Keyboard shortcuts

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