mirror of
https://github.com/labstack/echo.git
synced 2024-11-28 08:38:39 +02:00
Default bool config as false for middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
28fb57585b
commit
adad28012c
@ -16,7 +16,7 @@ type (
|
||||
// GzipConfig defines the config for gzip middleware.
|
||||
GzipConfig struct {
|
||||
// Level is the gzip level.
|
||||
// Optional with default value as `DefaultGzipConfig.Level`.
|
||||
// Optional with default value as -1.
|
||||
Level int
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ type (
|
||||
Format string
|
||||
|
||||
// Output is the writer where logs are written.
|
||||
// Optional with default value as `DefaultLoggerConfig.Output`.
|
||||
// Optional with default value as os.Stdout.
|
||||
Output io.Writer
|
||||
|
||||
template *fasttemplate.Template
|
||||
|
@ -12,17 +12,17 @@ type (
|
||||
// RecoverConfig defines the config for recover middleware.
|
||||
RecoverConfig struct {
|
||||
// StackSize is the stack size to be printed.
|
||||
// Optional with default value as `DefaultRecoverConfig.StackSize`.
|
||||
// Optional with default value as 4 KB.
|
||||
StackSize int
|
||||
|
||||
// StackAll is a flag to format stack traces of all other goroutines into
|
||||
// buffer after the trace for the current goroutine, or not.
|
||||
// Required.
|
||||
StackAll bool
|
||||
// DisableStackAll disables formatting stack traces of all other goroutines
|
||||
// into buffer after the trace for the current goroutine.
|
||||
// Optional with default value as false.
|
||||
DisableStackAll bool
|
||||
|
||||
// PrintStack is a flag to print stack or not.
|
||||
// Required.
|
||||
PrintStack bool
|
||||
// DisablePrintStack disables printing stack trace.
|
||||
// Optional with default value as false.
|
||||
DisablePrintStack bool
|
||||
}
|
||||
)
|
||||
|
||||
@ -30,8 +30,8 @@ var (
|
||||
// DefaultRecoverConfig is the default recover middleware config.
|
||||
DefaultRecoverConfig = RecoverConfig{
|
||||
StackSize: 4 << 10, // 4 KB
|
||||
StackAll: true,
|
||||
PrintStack: true,
|
||||
DisableStackAll: false,
|
||||
DisablePrintStack: false,
|
||||
}
|
||||
)
|
||||
|
||||
@ -61,8 +61,9 @@ func RecoverFromConfig(config RecoverConfig) echo.MiddlewareFunc {
|
||||
err = fmt.Errorf("%v", r)
|
||||
}
|
||||
stack := make([]byte, config.StackSize)
|
||||
length := runtime.Stack(stack, config.StackAll)
|
||||
if config.PrintStack {
|
||||
length := runtime.Stack(stack, !config.DisableStackAll)
|
||||
println(config.DisablePrintStack)
|
||||
if !config.DisablePrintStack {
|
||||
c.Logger().Printf("[%s] %s %s", color.Red("PANIC RECOVER"), err, stack[:length])
|
||||
}
|
||||
c.Error(err)
|
||||
|
@ -12,16 +12,16 @@ type (
|
||||
// StaticConfig defines the config for static middleware.
|
||||
StaticConfig struct {
|
||||
// Root is the directory from where the static content is served.
|
||||
// Optional with default value as `DefaultStaticConfig.Root`.
|
||||
// Optional with default value as "".
|
||||
Root string `json:"root"`
|
||||
|
||||
// Index is the list of index files to be searched and used when serving
|
||||
// a directory.
|
||||
// Optional with default value as `DefaultStaticConfig.Index`.
|
||||
// Optional with default value as []string{"index.html"}.
|
||||
Index []string `json:"index"`
|
||||
|
||||
// Browse is a flag to enable/disable directory browsing.
|
||||
// Required.
|
||||
// Optional with default value as false.
|
||||
Browse bool `json:"browse"`
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user