{"modulePath":"github.com/labStack/echo","version":"v3.3.10+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package middleware\n\n## Constants\n\n```go\nconst (\n\tAlgorithmHS256 = \"HS256\"\n)\n```\nAlgorithms\n\n## Variables\n\n```go\nvar (\n\t// DefaultBasicAuthConfig is the default BasicAuth middleware config.\n\tDefaultBasicAuthConfig = BasicAuthConfig{\n\t\tSkipper: DefaultSkipper,\n\t\tRealm:   defaultRealm,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultBodyDumpConfig is the default BodyDump middleware config.\n\tDefaultBodyDumpConfig = BodyDumpConfig{\n\t\tSkipper: DefaultSkipper,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultBodyLimitConfig is the default BodyLimit middleware config.\n\tDefaultBodyLimitConfig = BodyLimitConfig{\n\t\tSkipper: DefaultSkipper,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultCORSConfig is the default CORS middleware config.\n\tDefaultCORSConfig = CORSConfig{\n\t\tSkipper:      DefaultSkipper,\n\t\tAllowOrigins: []string{\"*\"},\n\t\tAllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultCSRFConfig is the default CSRF middleware config.\n\tDefaultCSRFConfig = CSRFConfig{\n\t\tSkipper:      DefaultSkipper,\n\t\tTokenLength:  32,\n\t\tTokenLookup:  \"header:\" + echo.HeaderXCSRFToken,\n\t\tContextKey:   \"csrf\",\n\t\tCookieName:   \"_csrf\",\n\t\tCookieMaxAge: 86400,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultGzipConfig is the default Gzip middleware config.\n\tDefaultGzipConfig = GzipConfig{\n\t\tSkipper: DefaultSkipper,\n\t\tLevel:   -1,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultJWTConfig is the default JWT auth middleware config.\n\tDefaultJWTConfig = JWTConfig{\n\t\tSkipper:       DefaultSkipper,\n\t\tSigningMethod: AlgorithmHS256,\n\t\tContextKey:    \"user\",\n\t\tTokenLookup:   \"header:\" + echo.HeaderAuthorization,\n\t\tAuthScheme:    \"Bearer\",\n\t\tClaims:        jwt.MapClaims{},\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultKeyAuthConfig is the default KeyAuth middleware config.\n\tDefaultKeyAuthConfig = KeyAuthConfig{\n\t\tSkipper:    DefaultSkipper,\n\t\tKeyLookup:  \"header:\" + echo.HeaderAuthorization,\n\t\tAuthScheme: \"Bearer\",\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultLoggerConfig is the default Logger middleware config.\n\tDefaultLoggerConfig = LoggerConfig{\n\t\tSkipper: DefaultSkipper,\n\t\tFormat: `{\"time\":\"${time_rfc3339_nano}\",\"id\":\"${id}\",\"remote_ip\":\"${remote_ip}\",` +\n\t\t\t`\"host\":\"${host}\",\"method\":\"${method}\",\"uri\":\"${uri}\",\"user_agent\":\"${user_agent}\",` +\n\t\t\t`\"status\":${status},\"error\":\"${error}\",\"latency\":${latency},\"latency_human\":\"${latency_human}\"` +\n\t\t\t`,\"bytes_in\":${bytes_in},\"bytes_out\":${bytes_out}}` + \"\\n\",\n\t\tCustomTimeFormat: \"2006-01-02 15:04:05.00000\",\n\t\tOutput:           os.Stdout,\n\t\t// contains filtered or unexported fields\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultMethodOverrideConfig is the default MethodOverride middleware config.\n\tDefaultMethodOverrideConfig = MethodOverrideConfig{\n\t\tSkipper: DefaultSkipper,\n\t\tGetter:  MethodFromHeader(echo.HeaderXHTTPMethodOverride),\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultProxyConfig is the default Proxy middleware config.\n\tDefaultProxyConfig = ProxyConfig{\n\t\tSkipper:    DefaultSkipper,\n\t\tContextKey: \"target\",\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultRecoverConfig is the default Recover middleware config.\n\tDefaultRecoverConfig = RecoverConfig{\n\t\tSkipper:           DefaultSkipper,\n\t\tStackSize:         4 \u003c\u003c 10,\n\t\tDisableStackAll:   false,\n\t\tDisablePrintStack: false,\n\t}\n)\n```\n\n```go\nvar DefaultRedirectConfig = RedirectConfig{\n\tSkipper: DefaultSkipper,\n\tCode:    http.StatusMovedPermanently,\n}\n```\nDefaultRedirectConfig is the default Redirect middleware config.\n\n```go\nvar (\n\t// DefaultRequestIDConfig is the default RequestID middleware config.\n\tDefaultRequestIDConfig = RequestIDConfig{\n\t\tSkipper:   DefaultSkipper,\n\t\tGenerator: generator,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultRewriteConfig is the default Rewrite middleware config.\n\tDefaultRewriteConfig = RewriteConfig{\n\t\tSkipper: DefaultSkipper,\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultSecureConfig is the default Secure middleware config.\n\tDefaultSecureConfig = SecureConfig{\n\t\tSkipper:            DefaultSkipper,\n\t\tXSSProtection:      \"1; mode=block\",\n\t\tContentTypeNosniff: \"nosniff\",\n\t\tXFrameOptions:      \"SAMEORIGIN\",\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultStaticConfig is the default Static middleware config.\n\tDefaultStaticConfig = StaticConfig{\n\t\tSkipper: DefaultSkipper,\n\t\tIndex:   \"index.html\",\n\t}\n)\n```\n\n```go\nvar (\n\t// DefaultTrailingSlashConfig is the default TrailingSlash middleware config.\n\tDefaultTrailingSlashConfig = TrailingSlashConfig{\n\t\tSkipper: DefaultSkipper,\n\t}\n)\n```\n\n```go\nvar (\n\tErrJWTMissing = echo.NewHTTPError(http.StatusBadRequest, \"missing or malformed jwt\")\n)\n```\nErrors\n\n## Functions\n\n```go\nfunc AddTrailingSlash() echo.MiddlewareFunc\n```\nAddTrailingSlash returns a root level (before router) middleware which adds a trailing slash to the request \\`URL#Path\\`.\n\nUsage \\`Echo#Pre(AddTrailingSlash())\\`\n\n```go\nfunc AddTrailingSlashWithConfig(config TrailingSlashConfig) echo.MiddlewareFunc\n```\nAddTrailingSlashWithConfig returns a AddTrailingSlash middleware with config. See \\`AddTrailingSlash()\\`.\n\n```go\nfunc BasicAuth(fn BasicAuthValidator) echo.MiddlewareFunc\n```\nBasicAuth returns an BasicAuth middleware.\n\nFor valid credentials it calls the next handler. For missing or invalid credentials, it sends \"401 - Unauthorized\" response.\n\n```go\nfunc BasicAuthWithConfig(config BasicAuthConfig) echo.MiddlewareFunc\n```\nBasicAuthWithConfig returns an BasicAuth middleware with config. See \\`BasicAuth()\\`.\n\n```go\nfunc BodyDump(handler BodyDumpHandler) echo.MiddlewareFunc\n```\nBodyDump returns a BodyDump middleware.\n\nBodyLimit middleware captures the request and response payload and calls the registered handler.\n\n```go\nfunc BodyDumpWithConfig(config BodyDumpConfig) echo.MiddlewareFunc\n```\nBodyDumpWithConfig returns a BodyDump middleware with config. See: \\`BodyDump()\\`.\n\n```go\nfunc BodyLimit(limit string) echo.MiddlewareFunc\n```\nBodyLimit returns a BodyLimit middleware.\n\nBodyLimit 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. Limit can be specified as \\`4x\\` or \\`4xB\\`, where x is one of the multiple from K, M, G, T or P.\n\n```go\nfunc BodyLimitWithConfig(config BodyLimitConfig) echo.MiddlewareFunc\n```\nBodyLimitWithConfig returns a BodyLimit middleware with config. See: \\`BodyLimit()\\`.\n\n```go\nfunc CORS() echo.MiddlewareFunc\n```\nCORS returns a Cross-Origin Resource Sharing (CORS) middleware. See: [https://developer.mozilla.org/en/docs/Web/HTTP/Access\\_control\\_CORS](https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS)\n\n```go\nfunc CORSWithConfig(config CORSConfig) echo.MiddlewareFunc\n```\nCORSWithConfig returns a CORS middleware with config. See: \\`CORS()\\`.\n\n```go\nfunc CSRF() echo.MiddlewareFunc\n```\nCSRF returns a Cross-Site Request Forgery (CSRF) middleware. See: [https://en.wikipedia.org/wiki/Cross-site\\_request\\_forgery](https://en.wikipedia.org/wiki/Cross-site_request_forgery)\n\n```go\nfunc CSRFWithConfig(config CSRFConfig) echo.MiddlewareFunc\n```\nCSRFWithConfig returns a CSRF middleware with config. See \\`CSRF()\\`.\n\n```go\nfunc DefaultSkipper(echo.Context) bool\n```\nDefaultSkipper returns false which processes the middleware.\n\n```go\nfunc Gzip() echo.MiddlewareFunc\n```\nGzip returns a middleware which compresses HTTP response using gzip compression scheme.\n\n```go\nfunc GzipWithConfig(config GzipConfig) echo.MiddlewareFunc\n```\nGzipWithConfig return Gzip middleware with config. See: \\`Gzip()\\`.\n\n```go\nfunc HTTPSNonWWWRedirect() echo.MiddlewareFunc\n```\nHTTPSNonWWWRedirect redirects http requests to https non www. For example, [http://www.labstack.com](http://www.labstack.com) will be redirect to [https://labstack.com](https://labstack.com).\n\nUsage \\`Echo#Pre(HTTPSNonWWWRedirect())\\`\n\n```go\nfunc HTTPSNonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc\n```\nHTTPSNonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. See \\`HTTPSNonWWWRedirect()\\`.\n\n```go\nfunc HTTPSRedirect() echo.MiddlewareFunc\n```\nHTTPSRedirect redirects http requests to https. For example, [http://labstack.com](http://labstack.com) will be redirect to [https://labstack.com](https://labstack.com).\n\nUsage \\`Echo#Pre(HTTPSRedirect())\\`\n\n```go\nfunc HTTPSRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc\n```\nHTTPSRedirectWithConfig returns an HTTPSRedirect middleware with config. See \\`HTTPSRedirect()\\`.\n\n```go\nfunc HTTPSWWWRedirect() echo.MiddlewareFunc\n```\nHTTPSWWWRedirect redirects http requests to https www. For example, [http://labstack.com](http://labstack.com) will be redirect to [https://www.labstack.com](https://www.labstack.com).\n\nUsage \\`Echo#Pre(HTTPSWWWRedirect())\\`\n\n```go\nfunc HTTPSWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc\n```\nHTTPSWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. See \\`HTTPSWWWRedirect()\\`.\n\n```go\nfunc JWT(key interface{}) echo.MiddlewareFunc\n```\nJWT returns a JSON Web Token (JWT) auth middleware.\n\nFor valid token, it sets the user in context and calls next handler. For invalid token, it returns \"401 - Unauthorized\" error. For missing token, it returns \"400 - Bad Request\" error.\n\nSee: [https://jwt.io/introduction](https://jwt.io/introduction) See \\`JWTConfig.TokenLookup\\`\n\n```go\nfunc JWTWithConfig(config JWTConfig) echo.MiddlewareFunc\n```\nJWTWithConfig returns a JWT auth middleware with config. See: \\`JWT()\\`.\n\n```go\nfunc KeyAuth(fn KeyAuthValidator) echo.MiddlewareFunc\n```\nKeyAuth returns an KeyAuth middleware.\n\nFor valid key it calls the next handler. For invalid key, it sends \"401 - Unauthorized\" response. For missing key, it sends \"400 - Bad Request\" response.\n\n```go\nfunc KeyAuthWithConfig(config KeyAuthConfig) echo.MiddlewareFunc\n```\nKeyAuthWithConfig returns an KeyAuth middleware with config. See \\`KeyAuth()\\`.\n\n```go\nfunc Logger() echo.MiddlewareFunc\n```\nLogger returns a middleware that logs HTTP requests.\n\n```go\nfunc LoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc\n```\nLoggerWithConfig returns a Logger middleware with config. See: \\`Logger()\\`.\n\n```go\nfunc MethodOverride() echo.MiddlewareFunc\n```\nMethodOverride returns a MethodOverride middleware. MethodOverride  middleware checks for the overridden method from the request and uses it instead of the original method.\n\nFor security reasons, only \\`POST\\` method can be overridden.\n\n```go\nfunc MethodOverrideWithConfig(config MethodOverrideConfig) echo.MiddlewareFunc\n```\nMethodOverrideWithConfig returns a MethodOverride middleware with config. See: \\`MethodOverride()\\`.\n\n```go\nfunc NonWWWRedirect() echo.MiddlewareFunc\n```\nNonWWWRedirect redirects www requests to non www. For example, [http://www.labstack.com](http://www.labstack.com) will be redirect to [http://labstack.com](http://labstack.com).\n\nUsage \\`Echo#Pre(NonWWWRedirect())\\`\n\n```go\nfunc NonWWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc\n```\nNonWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. See \\`NonWWWRedirect()\\`.\n\n```go\nfunc Proxy(balancer ProxyBalancer) echo.MiddlewareFunc\n```\nProxy returns a Proxy middleware.\n\nProxy middleware forwards the request to upstream server using a configured load balancing technique.\n\n```go\nfunc ProxyWithConfig(config ProxyConfig) echo.MiddlewareFunc\n```\nProxyWithConfig returns a Proxy middleware with config. See: \\`Proxy()\\`\n\n```go\nfunc Recover() echo.MiddlewareFunc\n```\nRecover returns a middleware which recovers from panics anywhere in the chain and handles the control to the centralized HTTPErrorHandler.\n\n```go\nfunc RecoverWithConfig(config RecoverConfig) echo.MiddlewareFunc\n```\nRecoverWithConfig returns a Recover middleware with config. See: \\`Recover()\\`.\n\n```go\nfunc RemoveTrailingSlash() echo.MiddlewareFunc\n```\nRemoveTrailingSlash returns a root level (before router) middleware which removes a trailing slash from the request URI.\n\nUsage \\`Echo#Pre(RemoveTrailingSlash())\\`\n\n```go\nfunc RemoveTrailingSlashWithConfig(config TrailingSlashConfig) echo.MiddlewareFunc\n```\nRemoveTrailingSlashWithConfig returns a RemoveTrailingSlash middleware with config. See \\`RemoveTrailingSlash()\\`.\n\n```go\nfunc RequestID() echo.MiddlewareFunc\n```\nRequestID returns a X-Request-ID middleware.\n\n```go\nfunc RequestIDWithConfig(config RequestIDConfig) echo.MiddlewareFunc\n```\nRequestIDWithConfig returns a X-Request-ID middleware with config.\n\n```go\nfunc Rewrite(rules map[string]string) echo.MiddlewareFunc\n```\nRewrite returns a Rewrite middleware.\n\nRewrite middleware rewrites the URL path based on the provided rules.\n\n```go\nfunc RewriteWithConfig(config RewriteConfig) echo.MiddlewareFunc\n```\nRewriteWithConfig returns a Rewrite middleware with config. See: \\`Rewrite()\\`.\n\n```go\nfunc Secure() echo.MiddlewareFunc\n```\nSecure returns a Secure middleware. Secure middleware provides protection against cross-site scripting (XSS) attack, content type sniffing, clickjacking, insecure connection and other code injection attacks.\n\n```go\nfunc SecureWithConfig(config SecureConfig) echo.MiddlewareFunc\n```\nSecureWithConfig returns a Secure middleware with config. See: \\`Secure()\\`.\n\n```go\nfunc Static(root string) echo.MiddlewareFunc\n```\nStatic returns a Static middleware to serves static content from the provided root directory.\n\n```go\nfunc StaticWithConfig(config StaticConfig) echo.MiddlewareFunc\n```\nStaticWithConfig returns a Static middleware with config. See \\`Static()\\`.\n\n```go\nfunc WWWRedirect() echo.MiddlewareFunc\n```\nWWWRedirect redirects non www requests to www. For example, [http://labstack.com](http://labstack.com) will be redirect to [http://www.labstack.com](http://www.labstack.com).\n\nUsage \\`Echo#Pre(WWWRedirect())\\`\n\n```go\nfunc WWWRedirectWithConfig(config RedirectConfig) echo.MiddlewareFunc\n```\nWWWRedirectWithConfig returns an HTTPSRedirect middleware with config. See \\`WWWRedirect()\\`.\n\n## Types\n\n```go\ntype BasicAuthConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Validator is a function to validate BasicAuth credentials.\n\t// Required.\n\tValidator BasicAuthValidator\n\n\t// Realm is a string to define realm attribute of BasicAuth.\n\t// Default value \"Restricted\".\n\tRealm string\n}\n```\nBasicAuthConfig defines the config for BasicAuth middleware.\n\n```go\ntype BasicAuthValidator func(string, string, echo.Context) (bool, error)\n```\nBasicAuthValidator defines a function to validate BasicAuth credentials.\n\n```go\ntype BeforeFunc func(echo.Context)\n```\nBeforeFunc defines a function which is executed just before the middleware.\n\n```go\ntype BodyDumpConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Handler receives request and response payload.\n\t// Required.\n\tHandler BodyDumpHandler\n}\n```\nBodyDumpConfig defines the config for BodyDump middleware.\n\n```go\ntype BodyDumpHandler func(echo.Context, []byte, []byte)\n```\nBodyDumpHandler receives the request and response payload.\n\n```go\ntype BodyLimitConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Maximum allowed size for a request body, it can be specified\n\t// as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P.\n\tLimit string `yaml:\"limit\"`\n\t// contains filtered or unexported fields\n}\n```\nBodyLimitConfig defines the config for BodyLimit middleware.\n\n```go\ntype CORSConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// AllowOrigin defines a list of origins that may access the resource.\n\t// Optional. Default value []string{\"*\"}.\n\tAllowOrigins []string `yaml:\"allow_origins\"`\n\n\t// AllowMethods defines a list methods allowed when accessing the resource.\n\t// This is used in response to a preflight request.\n\t// Optional. Default value DefaultCORSConfig.AllowMethods.\n\tAllowMethods []string `yaml:\"allow_methods\"`\n\n\t// AllowHeaders defines a list of request headers that can be used when\n\t// making the actual request. This is in response to a preflight request.\n\t// Optional. Default value []string{}.\n\tAllowHeaders []string `yaml:\"allow_headers\"`\n\n\t// AllowCredentials indicates whether or not the response to the request\n\t// can be exposed when the credentials flag is true. When used as part of\n\t// a response to a preflight request, this indicates whether or not the\n\t// actual request can be made using credentials.\n\t// Optional. Default value false.\n\tAllowCredentials bool `yaml:\"allow_credentials\"`\n\n\t// ExposeHeaders defines a whitelist headers that clients are allowed to\n\t// access.\n\t// Optional. Default value []string{}.\n\tExposeHeaders []string `yaml:\"expose_headers\"`\n\n\t// MaxAge indicates how long (in seconds) the results of a preflight request\n\t// can be cached.\n\t// Optional. Default value 0.\n\tMaxAge int `yaml:\"max_age\"`\n}\n```\nCORSConfig defines the config for CORS middleware.\n\n```go\ntype CSRFConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// TokenLength is the length of the generated token.\n\tTokenLength uint8 `yaml:\"token_length\"`\n\n\t// TokenLookup is a string in the form of \"\u003csource\u003e:\u003ckey\u003e\" that is used\n\t// to extract token from the request.\n\t// Optional. Default value \"header:X-CSRF-Token\".\n\t// Possible values:\n\t// - \"header:\u003cname\u003e\"\n\t// - \"form:\u003cname\u003e\"\n\t// - \"query:\u003cname\u003e\"\n\tTokenLookup string `yaml:\"token_lookup\"`\n\n\t// Context key to store generated CSRF token into context.\n\t// Optional. Default value \"csrf\".\n\tContextKey string `yaml:\"context_key\"`\n\n\t// Name of the CSRF cookie. This cookie will store CSRF token.\n\t// Optional. Default value \"csrf\".\n\tCookieName string `yaml:\"cookie_name\"`\n\n\t// Domain of the CSRF cookie.\n\t// Optional. Default value none.\n\tCookieDomain string `yaml:\"cookie_domain\"`\n\n\t// Path of the CSRF cookie.\n\t// Optional. Default value none.\n\tCookiePath string `yaml:\"cookie_path\"`\n\n\t// Max age (in seconds) of the CSRF cookie.\n\t// Optional. Default value 86400 (24hr).\n\tCookieMaxAge int `yaml:\"cookie_max_age\"`\n\n\t// Indicates if CSRF cookie is secure.\n\t// Optional. Default value false.\n\tCookieSecure bool `yaml:\"cookie_secure\"`\n\n\t// Indicates if CSRF cookie is HTTP only.\n\t// Optional. Default value false.\n\tCookieHTTPOnly bool `yaml:\"cookie_http_only\"`\n}\n```\nCSRFConfig defines the config for CSRF middleware.\n\n```go\ntype GzipConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Gzip compression level.\n\t// Optional. Default value -1.\n\tLevel int `yaml:\"level\"`\n}\n```\nGzipConfig defines the config for Gzip middleware.\n\n```go\ntype JWTConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// BeforeFunc defines a function which is executed just before the middleware.\n\tBeforeFunc BeforeFunc\n\n\t// SuccessHandler defines a function which is executed for a valid token.\n\tSuccessHandler JWTSuccessHandler\n\n\t// ErrorHandler defines a function which is executed for an invalid token.\n\t// It may be used to define a custom JWT error.\n\tErrorHandler JWTErrorHandler\n\n\t// Signing key to validate token.\n\t// Required.\n\tSigningKey interface{}\n\n\t// Signing method, used to check token signing method.\n\t// Optional. Default value HS256.\n\tSigningMethod string\n\n\t// Context key to store user information from the token into context.\n\t// Optional. Default value \"user\".\n\tContextKey string\n\n\t// Claims are extendable claims data defining token content.\n\t// Optional. Default value jwt.MapClaims\n\tClaims jwt.Claims\n\n\t// TokenLookup is a string in the form of \"\u003csource\u003e:\u003cname\u003e\" that is used\n\t// to extract token from the request.\n\t// Optional. Default value \"header:Authorization\".\n\t// Possible values:\n\t// - \"header:\u003cname\u003e\"\n\t// - \"query:\u003cname\u003e\"\n\t// - \"cookie:\u003cname\u003e\"\n\tTokenLookup string\n\n\t// AuthScheme to be used in the Authorization header.\n\t// Optional. Default value \"Bearer\".\n\tAuthScheme string\n\t// contains filtered or unexported fields\n}\n```\nJWTConfig defines the config for JWT middleware.\n\n```go\ntype JWTErrorHandler func(error) error\n```\nJWTErrorHandler defines a function which is executed for an invalid token.\n\n```go\ntype JWTSuccessHandler func(echo.Context)\n```\nJWTSuccessHandler defines a function which is executed for a valid token.\n\n```go\ntype KeyAuthConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// KeyLookup is a string in the form of \"\u003csource\u003e:\u003cname\u003e\" that is used\n\t// to extract key from the request.\n\t// Optional. Default value \"header:Authorization\".\n\t// Possible values:\n\t// - \"header:\u003cname\u003e\"\n\t// - \"query:\u003cname\u003e\"\n\t// - \"form:\u003cname\u003e\"\n\tKeyLookup string `yaml:\"key_lookup\"`\n\n\t// AuthScheme to be used in the Authorization header.\n\t// Optional. Default value \"Bearer\".\n\tAuthScheme string\n\n\t// Validator is a function to validate key.\n\t// Required.\n\tValidator KeyAuthValidator\n}\n```\nKeyAuthConfig defines the config for KeyAuth middleware.\n\n```go\ntype KeyAuthValidator func(string, echo.Context) (bool, error)\n```\nKeyAuthValidator defines a function to validate KeyAuth credentials.\n\n```go\ntype LoggerConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Tags to constructed the logger format.\n\t//\n\t// - time_unix\n\t// - time_unix_nano\n\t// - time_rfc3339\n\t// - time_rfc3339_nano\n\t// - time_custom\n\t// - id (Request ID)\n\t// - remote_ip\n\t// - uri\n\t// - host\n\t// - method\n\t// - path\n\t// - protocol\n\t// - referer\n\t// - user_agent\n\t// - status\n\t// - error\n\t// - latency (In nanoseconds)\n\t// - latency_human (Human readable)\n\t// - bytes_in (Bytes received)\n\t// - bytes_out (Bytes sent)\n\t// - header:\u003cNAME\u003e\n\t// - query:\u003cNAME\u003e\n\t// - form:\u003cNAME\u003e\n\t//\n\t// Example \"${remote_ip} ${status}\"\n\t//\n\t// Optional. Default value DefaultLoggerConfig.Format.\n\tFormat string `yaml:\"format\"`\n\n\t// Optional. Default value DefaultLoggerConfig.CustomTimeFormat.\n\tCustomTimeFormat string `yaml:\"custom_time_format\"`\n\n\t// Output is a writer where logs in JSON format are written.\n\t// Optional. Default value os.Stdout.\n\tOutput io.Writer\n\t// contains filtered or unexported fields\n}\n```\nLoggerConfig defines the config for Logger middleware.\n\n```go\ntype MethodOverrideConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Getter is a function that gets overridden method from the request.\n\t// Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride).\n\tGetter MethodOverrideGetter\n}\n```\nMethodOverrideConfig defines the config for MethodOverride middleware.\n\n```go\ntype MethodOverrideGetter func(echo.Context) string\n```\nMethodOverrideGetter is a function that gets overridden method from the request\n\n```go\nfunc MethodFromForm(param string) MethodOverrideGetter\n```\nMethodFromForm is a \\`MethodOverrideGetter\\` that gets overridden method from the form parameter.\n\n```go\nfunc MethodFromHeader(header string) MethodOverrideGetter\n```\nMethodFromHeader is a \\`MethodOverrideGetter\\` that gets overridden method from the request header.\n\n```go\nfunc MethodFromQuery(param string) MethodOverrideGetter\n```\nMethodFromQuery is a \\`MethodOverrideGetter\\` that gets overridden method from the query parameter.\n\n```go\ntype ProxyBalancer interface {\n\tAddTarget(*ProxyTarget) bool\n\tRemoveTarget(string) bool\n\tNext(echo.Context) *ProxyTarget\n}\n```\nProxyBalancer defines an interface to implement a load balancing technique.\n\n```go\nfunc NewRandomBalancer(targets []*ProxyTarget) ProxyBalancer\n```\nNewRandomBalancer returns a random proxy balancer.\n\n```go\nfunc NewRoundRobinBalancer(targets []*ProxyTarget) ProxyBalancer\n```\nNewRoundRobinBalancer returns a round-robin proxy balancer.\n\n```go\ntype ProxyConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Balancer defines a load balancing technique.\n\t// Required.\n\tBalancer ProxyBalancer\n\n\t// Rewrite defines URL path rewrite rules. The values captured in asterisk can be\n\t// retrieved by index e.g. $1, $2 and so on.\n\t// Examples:\n\t// \"/old\":              \"/new\",\n\t// \"/api/*\":            \"/$1\",\n\t// \"/js/*\":             \"/public/javascripts/$1\",\n\t// \"/users/*/orders/*\": \"/user/$1/order/$2\",\n\tRewrite map[string]string\n\n\t// Context key to store selected ProxyTarget into context.\n\t// Optional. Default value \"target\".\n\tContextKey string\n\n\t// To customize the transport to remote.\n\t// Examples: If custom TLS certificates are required.\n\tTransport http.RoundTripper\n\t// contains filtered or unexported fields\n}\n```\nProxyConfig defines the config for Proxy middleware.\n\n```go\ntype ProxyTarget struct {\n\tName string\n\tURL  *url.URL\n\tMeta echo.Map\n}\n```\nProxyTarget defines the upstream target.\n\n```go\ntype RecoverConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Size of the stack to be printed.\n\t// Optional. Default value 4KB.\n\tStackSize int `yaml:\"stack_size\"`\n\n\t// DisableStackAll disables formatting stack traces of all other goroutines\n\t// into buffer after the trace for the current goroutine.\n\t// Optional. Default value false.\n\tDisableStackAll bool `yaml:\"disable_stack_all\"`\n\n\t// DisablePrintStack disables printing stack trace.\n\t// Optional. Default value as false.\n\tDisablePrintStack bool `yaml:\"disable_print_stack\"`\n}\n```\nRecoverConfig defines the config for Recover middleware.\n\n```go\ntype RedirectConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper\n\n\t// Status code to be used when redirecting the request.\n\t// Optional. Default value http.StatusMovedPermanently.\n\tCode int `yaml:\"code\"`\n}\n```\nRedirectConfig defines the config for Redirect middleware.\n\n```go\ntype RequestIDConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Generator defines a function to generate an ID.\n\t// Optional. Default value random.String(32).\n\tGenerator func() string\n}\n```\nRequestIDConfig defines the config for RequestID middleware.\n\n```go\ntype RewriteConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Rules defines the URL path rewrite rules. The values captured in asterisk can be\n\t// retrieved by index e.g. $1, $2 and so on.\n\t// Example:\n\t// \"/old\":              \"/new\",\n\t// \"/api/*\":            \"/$1\",\n\t// \"/js/*\":             \"/public/javascripts/$1\",\n\t// \"/users/*/orders/*\": \"/user/$1/order/$2\",\n\t// Required.\n\tRules map[string]string `yaml:\"rules\"`\n\t// contains filtered or unexported fields\n}\n```\nRewriteConfig defines the config for Rewrite middleware.\n\n```go\ntype SecureConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// XSSProtection provides protection against cross-site scripting attack (XSS)\n\t// by setting the `X-XSS-Protection` header.\n\t// Optional. Default value \"1; mode=block\".\n\tXSSProtection string `yaml:\"xss_protection\"`\n\n\t// ContentTypeNosniff provides protection against overriding Content-Type\n\t// header by setting the `X-Content-Type-Options` header.\n\t// Optional. Default value \"nosniff\".\n\tContentTypeNosniff string `yaml:\"content_type_nosniff\"`\n\n\t// XFrameOptions can be used to indicate whether or not a browser should\n\t// be allowed to render a page in a \u003cframe\u003e, \u003ciframe\u003e or \u003cobject\u003e .\n\t// Sites can use this to avoid clickjacking attacks, by ensuring that their\n\t// content is not embedded into other sites.provides protection against\n\t// clickjacking.\n\t// Optional. Default value \"SAMEORIGIN\".\n\t// Possible values:\n\t// - \"SAMEORIGIN\" - The page can only be displayed in a frame on the same origin as the page itself.\n\t// - \"DENY\" - The page cannot be displayed in a frame, regardless of the site attempting to do so.\n\t// - \"ALLOW-FROM uri\" - The page can only be displayed in a frame on the specified origin.\n\tXFrameOptions string `yaml:\"x_frame_options\"`\n\n\t// HSTSMaxAge sets the `Strict-Transport-Security` header to indicate how\n\t// long (in seconds) browsers should remember that this site is only to\n\t// be accessed using HTTPS. This reduces your exposure to some SSL-stripping\n\t// man-in-the-middle (MITM) attacks.\n\t// Optional. Default value 0.\n\tHSTSMaxAge int `yaml:\"hsts_max_age\"`\n\n\t// HSTSExcludeSubdomains won't include subdomains tag in the `Strict Transport Security`\n\t// header, excluding all subdomains from security policy. It has no effect\n\t// unless HSTSMaxAge is set to a non-zero value.\n\t// Optional. Default value false.\n\tHSTSExcludeSubdomains bool `yaml:\"hsts_exclude_subdomains\"`\n\n\t// ContentSecurityPolicy sets the `Content-Security-Policy` header providing\n\t// security against cross-site scripting (XSS), clickjacking and other code\n\t// injection attacks resulting from execution of malicious content in the\n\t// trusted web page context.\n\t// Optional. Default value \"\".\n\tContentSecurityPolicy string `yaml:\"content_security_policy\"`\n}\n```\nSecureConfig defines the config for Secure middleware.\n\n```go\ntype Skipper func(echo.Context) bool\n```\nSkipper defines a function to skip middleware. Returning true skips processing the middleware.\n\n```go\ntype StaticConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Root directory from where the static content is served.\n\t// Required.\n\tRoot string `yaml:\"root\"`\n\n\t// Index file for serving a directory.\n\t// Optional. Default value \"index.html\".\n\tIndex string `yaml:\"index\"`\n\n\t// Enable HTML5 mode by forwarding all not-found requests to root so that\n\t// SPA (single-page application) can handle the routing.\n\t// Optional. Default value false.\n\tHTML5 bool `yaml:\"html5\"`\n\n\t// Enable directory browsing.\n\t// Optional. Default value false.\n\tBrowse bool `yaml:\"browse\"`\n}\n```\nStaticConfig defines the config for Static middleware.\n\n```go\ntype TrailingSlashConfig struct {\n\t// Skipper defines a function to skip middleware.\n\tSkipper Skipper\n\n\t// Status code to be used when redirecting the request.\n\t// Optional, but when provided the request is redirected using this code.\n\tRedirectCode int `yaml:\"redirect_code\"`\n}\n```\nTrailingSlashConfig defines the config for TrailingSlash middleware.\n\n","path":"github.com/labStack/echo/middleware","name":"middleware","synopsis":"","isRedistributable":true}
