security

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) route.Middleware

New creates the default security middleware chain.

Types

type Config

type Config struct {
	Next func(ctx *route.Context) bool

	Env string

	Recover   bool
	RequestID bool
	RealIP    bool
	Logger    bool
	BodyLimit bool
	Timeout   bool
	Helmet    bool

	RecoverStack   bool
	BodyLimitValue string
	TimeoutValue   time.Duration
	TrustedProxies []string
	SkipPaths      []string
}

Config configures the security middleware preset.

type Option

type Option func(*Config)

Option configures Config.

func BodyLimit

func BodyLimit(value string) Option

BodyLimit sets request body limit.

func Development

func Development() Option

Development applies development-friendly defaults.

func Disable

func Disable(names ...string) Option

Disable disables named middlewares.

func Next

func Next(fn func(ctx *route.Context) bool) Option

Next skips the security chain for matching requests.

func Production

func Production() Option

Production applies production-friendly defaults.

func SkipPaths

func SkipPaths(values ...string) Option

SkipPaths excludes matching paths from access logging.

func Timeout

func Timeout(value time.Duration) Option

Timeout sets request timeout.

func TrustedProxies

func TrustedProxies(values ...string) Option

TrustedProxies sets trusted proxy list for real ip parsing.

Jump to

Keyboard shortcuts

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