middleware

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(options forge.CORSConfig) forge.MiddlewareFunc

CORS headers

func CacheControl

func CacheControl(maxAge string) fiber.Handler

func NoCache

func NoCache() fiber.Handler

func RateLimit

func RateLimit(config RateLimiterConfig) forge.MiddlewareFunc

func Recover

func Recover() forge.MiddlewareFunc

func RequestLogger

func RequestLogger() forge.MiddlewareFunc

func RequireAuth

func RequireAuth() forge.MiddlewareFunc

func SecurityHeaders

func SecurityHeaders() fiber.Handler

func Timeout

func Timeout(duration time.Duration) forge.MiddlewareFunc

func Validator

func Validator() forge.MiddlewareFunc

Types

type Middleware

type Middleware struct {
	SecurityHeaders fiber.Handler
	CacheControl    func(maxAge string) fiber.Handler
	NoCache         fiber.Handler
}

func New

func New() *Middleware

type MiddlewareConfig

type MiddlewareConfig struct {
	Recover         bool
	Logger          bool
	CORS            bool
	Compression     bool
	RequestID       bool
	BodyLimit       string
	ReadTimeout     time.Duration
	WriteTimeout    time.Duration
	CORSConfig      forge.CORSConfig
	SecurityHeaders bool
}

type MiddlewareOption

type MiddlewareOption func(*MiddlewareConfig)

func WithBodyLimit

func WithBodyLimit(limit string) MiddlewareOption

func WithCORSConfig

func WithCORSConfig(config forge.CORSConfig) MiddlewareOption

func WithSecurityHeaders

func WithSecurityHeaders() MiddlewareOption

func WithTimeouts

func WithTimeouts(read, write time.Duration) MiddlewareOption

func WithoutCORS

func WithoutCORS() MiddlewareOption

func WithoutCompression

func WithoutCompression() MiddlewareOption

func WithoutLogger

func WithoutLogger() MiddlewareOption

func WithoutRecover

func WithoutRecover() MiddlewareOption

func WithoutRequestID

func WithoutRequestID() MiddlewareOption

type RateLimiterConfig

type RateLimiterConfig struct {
	Max int

	Window   time.Duration
	KeyFunc  func(*forge.Context) string
	SkipFunc func(*forge.Context) bool
}

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
	Value   string `json:"value,omitempty"`
	Tag     string `json:"tag"`
}

type ValidationResult

type ValidationResult struct {
	Errors []ValidationError `json:"errors"`
}

func (*ValidationResult) ValidationFailed

func (vr *ValidationResult) ValidationFailed() bool

Jump to

Keyboard shortcuts

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