Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultBodyLimitConfig is the default BodyLimit middleware config. DefaultBodyLimitConfig = middleware.BodyLimitConfig{ Skipper: middleware.DefaultSkipper, Limit: "2M", } )
var ( // DefaultGzipConfig is the default Gzip middleware config. DefaultGzipConfig = middleware.GzipConfig{ Skipper: func(c echo.Context) bool { return strings.Contains(c.Path(), "swagger") || strings.Contains(c.Path(), "metrics") }, Level: 5, } )
var ( // DefaultRequestIDConfig is the default RequestID middleware config. DefaultRequestIDConfig = RequestIDConfig{ Skipper: middleware.DefaultSkipper, Generator: func() string { return ksuid.New().String() }, } )
Functions ¶
func BodyLimit ¶
func BodyLimit() echo.MiddlewareFunc
BodyLimit returns a BodyLimit middleware.
BodyLimit middleware sets the maximum allowed size for a request body, if the size exceeds the configured limit, it sends "413 - Request Entity Too Large" response. The BodyLimit is determined based on both `Content-Length` request header and actual content read, which makes it super secure.
func Gzip ¶
func Gzip() echo.MiddlewareFunc
Gzip returns a middleware which compresses HTTP response using gzip compression scheme.
func RequestID ¶
func RequestID() echo.MiddlewareFunc
RequestID returns a X-Request-ID middleware. Generate an uuid if request header X-Request-ID is empty. Prefix `be-` means it was generated by server instead of client.
func RequestIDWithConfig ¶
func RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc
RequestIDWithConfig returns a X-Request-ID middleware with config.
Types ¶
type RequestIDConfig ¶
type RequestIDConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper // Generator defines a function to generate an ID. // Optional. Default value random.String(32). Generator func() string }
RequestIDConfig defines the config for RequestID middleware.