Documentation ¶
Index ¶
- Variables
- func BasicAuth(f BasicAuthFunc) echo.MiddlewareFunc
- func BasicAuthFromConfig(config BasicAuthConfig) echo.MiddlewareFunc
- func Gzip() echo.MiddlewareFunc
- func GzipFromConfig(config GzipConfig) echo.MiddlewareFunc
- func Logger() echo.MiddlewareFunc
- func LoggerFromConfig(config LoggerConfig) echo.MiddlewareFunc
- func Recover() echo.MiddlewareFunc
- func RecoverFromConfig(config RecoverConfig) echo.MiddlewareFunc
- func Static(root string) echo.MiddlewareFunc
- func StaticFromConfig(config StaticConfig) echo.MiddlewareFunc
- type BasicAuthConfig
- type BasicAuthFunc
- type GzipConfig
- type LoggerConfig
- type RecoverConfig
- type StaticConfig
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultBasicAuthConfig is the default basic auth middleware config. DefaultBasicAuthConfig = BasicAuthConfig{} )
var ( // DefaultGzipConfig is the default gzip middleware config. DefaultGzipConfig = GzipConfig{ Level: gzip.DefaultCompression, } )
var ( // DefaultLoggerConfig is the default logger middleware config. DefaultLoggerConfig = LoggerConfig{ Format: "time=${time_rfc3339}, remote_ip=${remote_ip}, method=${method}, path=${path}, status=${status}, response_time=${response_time}, response_size=${response_size} bytes\n", Output: os.Stdout, // contains filtered or unexported fields } )
var ( // DefaultRecoverConfig is the default recover middleware config. DefaultRecoverConfig = RecoverConfig{ StackSize: 4 << 10, StackAll: true, PrintStack: true, } )
var ( // DefaultStaticConfig is the default static middleware config. DefaultStaticConfig = StaticConfig{ Index: "index.html", Browse: false, } )
Functions ¶
func BasicAuth ¶
func BasicAuth(f BasicAuthFunc) echo.MiddlewareFunc
BasicAuth returns an HTTP basic auth middleware.
For valid credentials it calls the next handler. For invalid credentials, it sends "401 - Unauthorized" response.
func BasicAuthFromConfig ¶
func BasicAuthFromConfig(config BasicAuthConfig) echo.MiddlewareFunc
BasicAuthFromConfig returns an HTTP basic auth middleware from config. See `BasicAuth()`.
func Gzip ¶ added in v0.0.13
func Gzip() echo.MiddlewareFunc
Gzip returns a middleware which compresses HTTP response using gzip compression scheme.
func GzipFromConfig ¶
func GzipFromConfig(config GzipConfig) echo.MiddlewareFunc
GzipFromConfig return gzip middleware from config. See `Gzip()`.
func Logger ¶
func Logger() echo.MiddlewareFunc
Logger returns a middleware that logs HTTP requests.
func LoggerFromConfig ¶
func LoggerFromConfig(config LoggerConfig) echo.MiddlewareFunc
LoggerFromConfig returns a logger middleware from config. See `Logger()`.
func Recover ¶ added in v0.0.13
func Recover() echo.MiddlewareFunc
Recover returns a middleware which recovers from panics anywhere in the chain and handles the control to the centralized HTTPErrorHandler.
func RecoverFromConfig ¶
func RecoverFromConfig(config RecoverConfig) echo.MiddlewareFunc
RecoverFromConfig returns a recover middleware from config. See `Recover()`.
func Static ¶
func Static(root string) echo.MiddlewareFunc
Static returns a static middleware to deliever static content from the provided root directory.
func StaticFromConfig ¶
func StaticFromConfig(config StaticConfig) echo.MiddlewareFunc
StaticFromConfig returns a static middleware from config. See `Static()`.
Types ¶
type BasicAuthConfig ¶
type BasicAuthConfig struct {
AuthFunc BasicAuthFunc
}
BasicAuthConfig defines config for HTTP basic auth middleware.
type BasicAuthFunc ¶
BasicAuthFunc defines a function to validate basic auth credentials.
type GzipConfig ¶
type GzipConfig struct { // Level is the gzip level. Level int }
GzipConfig defines config for gzip middleware.
type LoggerConfig ¶
type LoggerConfig struct { // Format is the log format. // // Example "${remote_id} ${status}" // Available tags: // - time_rfc3339 // - remote_ip // - method // - path // - status // - response_time // - response_size Format string // Output is the writer where logs are written. Default is `os.Stdout`. Output io.Writer // contains filtered or unexported fields }
LoggerConfig defines config for logger middleware.
type RecoverConfig ¶
type RecoverConfig struct { // StackSize is the stack size to be printed. StackSize int // StackAll is flag to format stack traces of all other goroutines into // buffer after the trace for the current goroutine, or not. Default is true. StackAll bool // PrintStack is the flag to print stack or not. Default is true. PrintStack bool }
RecoverConfig defines config for recover middleware.
type StaticConfig ¶
type StaticConfig struct { // Root is the directory from where the static content is served. Root string `json:"root"` // Index is the index file to be used while serving a directory. // Default is `index.html`. Index string `json:"index"` // Browse is the flag to list directory or not. Default is false. Browse bool `json:"browse"` }
StaticConfig defines config for static middleware.