Documentation
¶
Index ¶
- Variables
- func AccessLog(options ...AccessLogOption) inertia.HandlerFunc
- func Gzip(options ...GzipOption) inertia.HandlerFunc
- func HTTPDump() inertia.HandlerFunc
- func Recovery() inertia.HandlerFunc
- func RecoveryWithConfig(config RecoveryConfig) inertia.HandlerFunc
- type AccessLogOption
- type GzipOption
- type RecoveryConfig
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.
Click to show internal directories.
Click to hide internal directories.