middleware

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExcludedExtentions = []string{
	".png", ".gif", ".jpeg", ".jpg", ".js", ".css", ".woff", ".woff2", ".ttf", ".eot", ".svg", ".mp4", ".mp3", ".avi", ".mov", ".mkv", ".zip", ".rar", ".7z", ".gz", ".tar",
}

Functions

func AccessLog

func AccessLog(options ...AccessLogOption) inertia.HandlerFunc

AccessLog returns an inertia middleware that logs the request method, URL and duration. If out is nil the middleware uses the default logger (plain text, or JSON in production).

func Gzip

func Gzip(options ...GzipOption) inertia.HandlerFunc

func HTTPDump

func HTTPDump() inertia.HandlerFunc

HTTPDump is a middleware that dumps the request and response to the console.

func Recovery

func Recovery() inertia.HandlerFunc

Recovery is a middleware that recovers from panics and logs the error. The error stack trace is printed only when the application is in 'development' mode.

func RecoveryWithConfig

func RecoveryWithConfig(config RecoveryConfig) inertia.HandlerFunc

RecoveryWithConfig returns a Recovery middleware with config.

Types

type AccessLogOption

type AccessLogOption func(*accessLogOptions)

func WithAccessLogOutput

func WithAccessLogOutput(out io.Writer) AccessLogOption

type GzipOption

type GzipOption func(*gzipOptions)

func WithGzipExcludedExtentions

func WithGzipExcludedExtentions(exts []string) GzipOption

func WithGzipLevel

func WithGzipLevel(level int) GzipOption

func WithGzipShouldCompressFn

func WithGzipShouldCompressFn(fn func(req *http.Request) bool) GzipOption

type RecoveryConfig

type RecoveryConfig struct {
	// OutputWriter is where to write the error output. Default is os.Stderr.
	OutputWriter io.Writer
	// EnableStackTrace enables printing stack trace in development mode.
	EnableStackTrace bool
	// RecoveryHandler is a custom recovery handler.
	RecoveryHandler func(c *inertia.Context, err any)
}

RecoveryConfig defines the config for Recovery middleware.

func DefaultRecoveryConfig

func DefaultRecoveryConfig() RecoveryConfig

DefaultRecoveryConfig returns a default recovery config.

Jump to

Keyboard shortcuts

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