# Packages
Package echocontext adds the echo context to the parent context.
# Functions
AddTrailingSlash returns a root level (before router) middleware which adds a trailing slash to the request `URL#Path`.
AddTrailingSlashWithConfig returns an AddTrailingSlash middleware with config or panics on invalid configuration.
BasicAuth returns an BasicAuth middleware.
BasicAuthWithConfig returns an BasicAuthWithConfig middleware with config.
BodyDump returns a BodyDump middleware.
BodyDumpWithConfig returns a BodyDump middleware with config.
BodyLimit returns a BodyLimit middleware.
BodyLimitWithConfig returns a BodyLimitWithConfig middleware.
ContextTimeout returns a middleware which returns error (503 Service Unavailable error) to client when underlying method returns context.DeadlineExceeded error.
ContextTimeoutWithConfig returns a Timeout middleware with config.
CORS returns a Cross-Origin Resource Sharing (CORS) middleware.
CORSWithConfig returns a CORS middleware with config or panics on invalid configuration.
CreateExtractors creates ValuesExtractors from given lookups.
CSRF returns a Cross-Site Request Forgery (CSRF) middleware.
CSRFWithConfig returns a CSRF middleware with config or panics on invalid configuration.
Decompress decompresses request body based if content encoding type is set to "gzip" with default config.
DecompressWithConfig returns a decompress middleware with config or panics on invalid configuration.
DefaultSkipper returns false which processes the middleware.
Gzip returns a middleware which compresses HTTP response using gzip compression scheme.
GzipWithConfig returns a middleware which compresses HTTP response using gzip compression scheme.
HTTPSNonWWWRedirect redirects http requests to https non www.
HTTPSNonWWWRedirectWithConfig returns a HTTPS Non-WWW redirect middleware with config or panics on invalid configuration.
HTTPSRedirect redirects http requests to https.
HTTPSRedirectWithConfig returns a HTTPS redirect middleware with config or panics on invalid configuration.
HTTPSWWWRedirect redirects http requests to https www.
HTTPSWWWRedirectWithConfig returns a HTTPS WWW redirect middleware with config or panics on invalid configuration.
KeyAuth returns an KeyAuth middleware.
KeyAuthWithConfig returns an KeyAuth middleware or panics if configuration is invalid.
Logger returns a middleware that logs HTTP requests.
LoggerWithConfig returns a Logger middleware with config or panics on invalid configuration.
MethodFromForm is a `MethodOverrideGetter` that gets overridden method from the form parameter.
MethodFromHeader is a `MethodOverrideGetter` that gets overridden method from the request header.
MethodFromQuery is a `MethodOverrideGetter` that gets overridden method from the query parameter.
MethodOverride returns a MethodOverride middleware.
MethodOverrideWithConfig returns a Method Override middleware with config or panics on invalid configuration.
NewRandomBalancer returns a random proxy balancer.
NewRateLimiterMemoryStore returns an instance of RateLimiterMemoryStore with
the provided rate (as req/s).
NewRateLimiterMemoryStoreWithConfig returns an instance of RateLimiterMemoryStore
with the provided configuration.
NewRoundRobinBalancer returns a round-robin proxy balancer.
NonWWWRedirect redirects www requests to non www.
NonWWWRedirectWithConfig returns a Non-WWW redirect middleware with config or panics on invalid configuration.
Proxy returns a Proxy middleware.
ProxyWithConfig returns a Proxy middleware or panics if configuration is invalid.
RateLimiter returns a rate limiting middleware
e := echox.New()
limiterStore := middleware.NewRateLimiterMemoryStore(20)
e.GET("/rate-limited", func(c echox.Context) error {
return c.String(http.StatusOK, "test")
}, RateLimiter(limiterStore))
*/.
RateLimiterWithConfig returns a rate limiting middleware
e := echox.New()
config := middleware.RateLimiterConfig{
Skipper: DefaultSkipper,
Store: middleware.NewRateLimiterMemoryStore(
middleware.RateLimiterMemoryStoreConfig{Rate: 10, Burst: 30, ExpiresIn: 3 * time.Minute}
)
IdentifierExtractor: func(ctx echox.Context) (string, error) {
id := ctx.RealIP()
return id, nil
},
ErrorHandler: func(context echox.Context, err error) error {
return context.JSON(http.StatusTooManyRequests, nil)
},
DenyHandler: func(context echox.Context, identifier string) error {
return context.JSON(http.StatusForbidden, nil)
},
}
e.GET("/rate-limited", func(c echox.Context) error {
return c.String(http.StatusOK, "test")
}, middleware.RateLimiterWithConfig(config))
*/.
Recover returns a middleware which recovers from panics anywhere in the chain and handles the control to the centralized HTTPErrorHandler.
RecoverWithConfig returns a Recovery middleware with config or panics on invalid configuration.
RemoveTrailingSlash returns a root level (before router) middleware which removes a trailing slash from the request URI.
RemoveTrailingSlashWithConfig returns a RemoveTrailingSlash middleware with config or panics on invalid configuration.
RequestID returns a X-Request-ID middleware.
RequestIDWithConfig returns a X-Request-ID middleware with config or panics on invalid configuration.
RequestLoggerWithConfig returns a RequestLogger middleware with config.
Rewrite returns a Rewrite middleware.
RewriteWithConfig returns a Rewrite middleware or panics on invalid configuration.
Secure returns a Secure middleware.
SecureWithConfig returns a Secure middleware with config or panics on invalid configuration.
Static returns a Static middleware to serves static content from the provided root directory.
StaticWithConfig returns a Static middleware to serves static content or panics on invalid configuration.
WWWRedirect redirects non www requests to www.
WWWRedirectWithConfig returns a WWW redirect middleware with config or panics on invalid configuration.
# Constants
EB is 1 Exabyte = 1_152_921_504_606_847_000 bytes.
ExtractorSourceCookie means value was extracted from request cookies.
ExtractorSourceForm means value was extracted from request form values.
ExtractorSourceHeader means value was extracted from request header.
ExtractorSourcePathParam means value was extracted from route path parameters.
ExtractorSourceQuery means value was extracted from request query parameters.
GB is 1 Gigabyte = 1_073_741_824 bytes.
GZIPEncoding content-encoding header if set to "gzip", decompress body contents.
KB is 1 KiloByte = 1024 bytes.
MB is 1 Megabyte = 1_048_576 bytes.
PB is 1 Petabyte = 1_125_899_906_842_624 bytes.
StatusCodeContextCanceled is a custom HTTP status code for situations where a client unexpectedly closed the connection to the server.
TB is 1 Terabyte = 1_099_511_627_776 bytes.
# Variables
DefaultCORSConfig is the default CORS middleware config.
DefaultCSRFConfig is the default CSRF middleware config.
DefaultKeyAuthConfig is the default KeyAuth middleware config.
DefaultLoggerConfig is the default Logger middleware config.
DefaultMethodOverrideConfig is the default MethodOverride middleware config.
DefaultProxyConfig is the default Proxy middleware config.
DefaultRateLimiterConfig defines default values for RateLimiterConfig.
DefaultRateLimiterMemoryStoreConfig provides default configuration values for RateLimiterMemoryStore.
DefaultRecoverConfig is the default Recover middleware config.
DefaultSecureConfig is the default Secure middleware config.
DefaultStaticConfig is the default Static middleware config.
ErrCSRFInvalid is returned when CSRF check fails.
ErrExtractorError denotes an error raised when extractor function is unsuccessful.
ErrInvalidKey denotes an error raised when key value is invalid by validator.
ErrKeyMissing denotes an error raised when key value could not be extracted from request.
ErrRateLimitExceeded denotes an error raised when rate limit is exceeded.
RedirectHTTPSConfig is the HTTPS Redirect middleware config.
RedirectHTTPSWWWConfig is the HTTPS WWW Redirect middleware config.
RedirectNonHTTPSWWWConfig is the non HTTPS WWW Redirect middleware config.
RedirectNonWWWConfig is the non WWW Redirect middleware config.
RedirectWWWConfig is the WWW Redirect middleware config.
# Structs
AddTrailingSlashConfig is the middleware config for adding trailing slash to the request.
BasicAuthConfig defines the config for BasicAuthWithConfig middleware.
BodyDumpConfig defines the config for BodyDump middleware.
BodyLimitConfig defines the config for BodyLimitWithConfig middleware.
ContextTimeoutConfig defines the config for ContextTimeout middleware.
CORSConfig defines the config for CORS middleware.
CSRFConfig defines the config for CSRF middleware.
DecompressConfig defines the config for Decompress middleware.
DefaultGzipDecompressPool is the default implementation of Decompressor interface.
GzipConfig defines the config for Gzip middleware.
KeyAuthConfig defines the config for KeyAuth middleware.
LoggerConfig defines the config for Logger middleware.
MethodOverrideConfig defines the config for MethodOverride middleware.
ProxyConfig defines the config for Proxy middleware.
ProxyTarget defines the upstream target.
RateLimiterConfig defines the configuration for the rate limiter.
RateLimiterMemoryStore is the built-in store implementation for RateLimiter.
RateLimiterMemoryStoreConfig represents configuration for RateLimiterMemoryStore.
RecoverConfig defines the config for Recover middleware.
RedirectConfig defines the config for Redirect middleware.
RemoveTrailingSlashConfig is the middleware config for removing trailing slash from the request.
RequestIDConfig defines the config for RequestID middleware.
RequestLoggerConfig is configuration for Request Logger middleware.
RequestLoggerValues contains extracted values from logger.
RewriteConfig defines the config for Rewrite middleware.
SecureConfig defines the config for Secure middleware.
StaticConfig defines the config for Static middleware.
ValueExtractorError is error type when middleware extractor is unable to extract value from lookups.
Visitor signifies a unique user's limiter details.
# Interfaces
Decompressor is used to get the sync.Pool used by the middleware to get Gzip readers.
ProxyBalancer defines an interface to implement a load balancing technique.
RateLimiterStore is the interface to be implemented by custom stores.
# Type aliases
BasicAuthValidator defines a function to validate BasicAuthWithConfig credentials.
BeforeFunc defines a function which is executed just before the middleware.
BodyDumpHandler receives the request and response payload.
Extractor is used to extract data from echox.Context.
ExtractorSource is type to indicate source for extracted value.
KeyAuthErrorHandler defines a function which is executed for an invalid key.
KeyAuthValidator defines a function to validate KeyAuth credentials.
MethodOverrideGetter is a function that gets overridden method from the request.
Skipper defines a function to skip middleware.
ValuesExtractor defines a function for extracting values (keys/tokens) from the given context.