mirror of
https://github.com/labstack/echo.git
synced 2025-01-26 03:20:08 +02:00
Added json tags to middleware config
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
52a5dcf3cf
commit
c6b32d5541
@ -17,7 +17,7 @@ type (
|
||||
GzipConfig struct {
|
||||
// Gzip compression level.
|
||||
// Optional. Default value -1.
|
||||
Level int
|
||||
Level int `json:"level"`
|
||||
}
|
||||
|
||||
gzipResponseWriter struct {
|
||||
|
@ -13,34 +13,34 @@ type (
|
||||
CORSConfig struct {
|
||||
// AllowOrigin defines a list of origins that may access the resource.
|
||||
// Optional. Default value []string{"*"}.
|
||||
AllowOrigins []string
|
||||
AllowOrigins []string `json:"allow_origins"`
|
||||
|
||||
// AllowMethods defines a list methods allowed when accessing the resource.
|
||||
// This is used in response to a preflight request.
|
||||
// Optional. Default value DefaultCORSConfig.AllowMethods.
|
||||
AllowMethods []string
|
||||
AllowMethods []string `json:"allow_methods"`
|
||||
|
||||
// AllowHeaders defines a list of request headers that can be used when
|
||||
// making the actual request. This in response to a preflight request.
|
||||
// Optional. Default value []string{}.
|
||||
AllowHeaders []string
|
||||
AllowHeaders []string `json:"allow_headers"`
|
||||
|
||||
// AllowCredentials indicates whether or not the response to the request
|
||||
// can be exposed when the credentials flag is true. When used as part of
|
||||
// a response to a preflight request, this indicates whether or not the
|
||||
// actual request can be made using credentials.
|
||||
// Optional. Default value false.
|
||||
AllowCredentials bool
|
||||
AllowCredentials bool `json:"allow_credentials"`
|
||||
|
||||
// ExposeHeaders defines a whitelist headers that clients are allowed to
|
||||
// access.
|
||||
// Optional. Default value []string{}.
|
||||
ExposeHeaders []string
|
||||
ExposeHeaders []string `json:"expose_headers"`
|
||||
|
||||
// MaxAge indicates how long (in seconds) the results of a preflight request
|
||||
// can be cached.
|
||||
// Optional. Default value 0.
|
||||
MaxAge int
|
||||
MaxAge int `json:"max_age"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -18,11 +18,11 @@ type (
|
||||
// CSRFConfig defines the config for CSRF middleware.
|
||||
CSRFConfig struct {
|
||||
// Key to create CSRF token.
|
||||
Secret []byte
|
||||
Secret []byte `json:"secret"`
|
||||
|
||||
// Context key to store generated CSRF token into context.
|
||||
// Optional. Default value "csrf".
|
||||
ContextKey string
|
||||
ContextKey string `json:"context_key"`
|
||||
|
||||
// Extractor is a function that extracts token from the request.
|
||||
// Optional. Default value CSRFTokenFromHeader(echo.HeaderXCSRFToken).
|
||||
@ -30,27 +30,27 @@ type (
|
||||
|
||||
// Name of the CSRF cookie. This cookie will store CSRF token.
|
||||
// Optional. Default value "csrf".
|
||||
CookieName string
|
||||
CookieName string `json:"cookie_name"`
|
||||
|
||||
// Domain of the CSRF cookie.
|
||||
// Optional. Default value none.
|
||||
CookieDomain string
|
||||
CookieDomain string `json:"cookie_domain"`
|
||||
|
||||
// Path of the CSRF cookie.
|
||||
// Optional. Default value none.
|
||||
CookiePath string
|
||||
CookiePath string `json:"cookie_path"`
|
||||
|
||||
// Expiration time of the CSRF cookie.
|
||||
// Optional. Default value 24H.
|
||||
CookieExpires time.Time
|
||||
CookieExpires time.Time `json:"cookie_expires"`
|
||||
|
||||
// Indicates if CSRF cookie is secure.
|
||||
CookieSecure bool
|
||||
CookieSecure bool `json:"cookie_secure"`
|
||||
// Optional. Default value false.
|
||||
|
||||
// Indicates if CSRF cookie is HTTP only.
|
||||
// Optional. Default value false.
|
||||
CookieHTTPOnly bool
|
||||
CookieHTTPOnly bool `json:"cookie_http_only"`
|
||||
}
|
||||
|
||||
// CSRFTokenExtractor defines a function that takes `echo.Context` and returns
|
||||
|
@ -14,15 +14,15 @@ type (
|
||||
JWTConfig struct {
|
||||
// Signing key to validate token.
|
||||
// Required.
|
||||
SigningKey []byte
|
||||
SigningKey []byte `json:"signing_key"`
|
||||
|
||||
// Signing method, used to check token signing method.
|
||||
// Optional. Default value HS256.
|
||||
SigningMethod string
|
||||
SigningMethod string `json:"signing_method"`
|
||||
|
||||
// Context key to store user information from the token into context.
|
||||
// Optional. Default value "user".
|
||||
ContextKey string
|
||||
ContextKey string `json:"context_key"`
|
||||
|
||||
// Extractor is a function that extracts token from the request.
|
||||
// Optional. Default value JWTFromHeader.
|
||||
|
@ -39,7 +39,7 @@ type (
|
||||
// Example "${remote_ip} ${status}"
|
||||
//
|
||||
// Optional. Default value DefaultLoggerConfig.Format.
|
||||
Format string
|
||||
Format string `json:"format"`
|
||||
|
||||
// Output is a writer where logs are written.
|
||||
// Optional. Default value os.Stdout.
|
||||
|
@ -13,16 +13,16 @@ type (
|
||||
RecoverConfig struct {
|
||||
// Size of the stack to be printed.
|
||||
// Optional. Default value 4KB.
|
||||
StackSize int
|
||||
StackSize int `json:"stack_size"`
|
||||
|
||||
// DisableStackAll disables formatting stack traces of all other goroutines
|
||||
// into buffer after the trace for the current goroutine.
|
||||
// Optional. Default value false.
|
||||
DisableStackAll bool
|
||||
DisableStackAll bool `json:"disable_stack_all"`
|
||||
|
||||
// DisablePrintStack disables printing stack trace.
|
||||
// Optional. Default value as false.
|
||||
DisablePrintStack bool
|
||||
DisablePrintStack bool `json:"disable_print_stack"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -12,12 +12,12 @@ type (
|
||||
// XSSProtection provides protection against cross-site scripting attack (XSS)
|
||||
// by setting the `X-XSS-Protection` header.
|
||||
// Optional. Default value "1; mode=block".
|
||||
XSSProtection string
|
||||
XSSProtection string `json:"xss_protection"`
|
||||
|
||||
// ContentTypeNosniff provides protection against overriding Content-Type
|
||||
// header by setting the `X-Content-Type-Options` header.
|
||||
// Optional. Default value "nosniff".
|
||||
ContentTypeNosniff string
|
||||
ContentTypeNosniff string `json:"content_type_nosniff"`
|
||||
|
||||
// XFrameOptions can be used to indicate whether or not a browser should
|
||||
// be allowed to render a page in a <frame>, <iframe> or <object> .
|
||||
@ -29,27 +29,27 @@ type (
|
||||
// `SAMEORIGIN` - The page can only be displayed in a frame on the same origin as the page itself.
|
||||
// `DENY` - The page cannot be displayed in a frame, regardless of the site attempting to do so.
|
||||
// `ALLOW-FROM uri` - The page can only be displayed in a frame on the specified origin.
|
||||
XFrameOptions string
|
||||
XFrameOptions string `json:"x_frame_options"`
|
||||
|
||||
// HSTSMaxAge sets the `Strict-Transport-Security` header to indicate how
|
||||
// long (in seconds) browsers should remember that this site is only to
|
||||
// be accessed using HTTPS. This reduces your exposure to some SSL-stripping
|
||||
// man-in-the-middle (MITM) attacks.
|
||||
// Optional. Default value 0.
|
||||
HSTSMaxAge int
|
||||
HSTSMaxAge int `json:"hsts_max_age"`
|
||||
|
||||
// HSTSExcludeSubdomains won't include subdomains tag in the `Strict Transport Security`
|
||||
// header, excluding all subdomains from security policy. It has no effect
|
||||
// unless HSTSMaxAge is set to a non-zero value.
|
||||
// Optional. Default value false.
|
||||
HSTSExcludeSubdomains bool
|
||||
HSTSExcludeSubdomains bool `json:"hsts_exclude_subdomains"`
|
||||
|
||||
// ContentSecurityPolicy sets the `Content-Security-Policy` header providing
|
||||
// security against cross-site scripting (XSS), clickjacking and other code
|
||||
// injection attacks resulting from execution of malicious content in the
|
||||
// trusted web page context.
|
||||
// Optional. Default value "".
|
||||
ContentSecurityPolicy string
|
||||
ContentSecurityPolicy string `json:"content_security_policy"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,7 @@ type (
|
||||
TrailingSlashConfig struct {
|
||||
// Status code to be used when redirecting the request.
|
||||
// Optional, but when provided the request is redirected using this code.
|
||||
RedirectCode int
|
||||
RedirectCode int `json:"redirect_code"`
|
||||
}
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user