mirror of
				https://github.com/labstack/echo.git
				synced 2025-10-30 23:57:38 +02:00 
			
		
		
		
	Default bool config as false for middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
		| @@ -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,26 +12,26 @@ 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 | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// DefaultRecoverConfig is the default recover middleware config. | ||||
| 	DefaultRecoverConfig = RecoverConfig{ | ||||
| 		StackSize:  4 << 10, // 4 KB | ||||
| 		StackAll:   true, | ||||
| 		PrintStack: true, | ||||
| 		StackSize:         4 << 10, // 4 KB | ||||
| 		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"` | ||||
| 	} | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user