1
0
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:
Vishal Rana 2016-05-18 18:53:54 -07:00
parent 52a5dcf3cf
commit c6b32d5541
8 changed files with 29 additions and 29 deletions

View File

@ -17,7 +17,7 @@ type (
GzipConfig struct { GzipConfig struct {
// Gzip compression level. // Gzip compression level.
// Optional. Default value -1. // Optional. Default value -1.
Level int Level int `json:"level"`
} }
gzipResponseWriter struct { gzipResponseWriter struct {

View File

@ -13,34 +13,34 @@ type (
CORSConfig struct { CORSConfig struct {
// AllowOrigin defines a list of origins that may access the resource. // AllowOrigin defines a list of origins that may access the resource.
// Optional. Default value []string{"*"}. // Optional. Default value []string{"*"}.
AllowOrigins []string AllowOrigins []string `json:"allow_origins"`
// AllowMethods defines a list methods allowed when accessing the resource. // AllowMethods defines a list methods allowed when accessing the resource.
// This is used in response to a preflight request. // This is used in response to a preflight request.
// Optional. Default value DefaultCORSConfig.AllowMethods. // Optional. Default value DefaultCORSConfig.AllowMethods.
AllowMethods []string AllowMethods []string `json:"allow_methods"`
// AllowHeaders defines a list of request headers that can be used when // AllowHeaders defines a list of request headers that can be used when
// making the actual request. This in response to a preflight request. // making the actual request. This in response to a preflight request.
// Optional. Default value []string{}. // Optional. Default value []string{}.
AllowHeaders []string AllowHeaders []string `json:"allow_headers"`
// AllowCredentials indicates whether or not the response to the request // AllowCredentials indicates whether or not the response to the request
// can be exposed when the credentials flag is true. When used as part of // 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 // a response to a preflight request, this indicates whether or not the
// actual request can be made using credentials. // actual request can be made using credentials.
// Optional. Default value false. // Optional. Default value false.
AllowCredentials bool AllowCredentials bool `json:"allow_credentials"`
// ExposeHeaders defines a whitelist headers that clients are allowed to // ExposeHeaders defines a whitelist headers that clients are allowed to
// access. // access.
// Optional. Default value []string{}. // Optional. Default value []string{}.
ExposeHeaders []string ExposeHeaders []string `json:"expose_headers"`
// MaxAge indicates how long (in seconds) the results of a preflight request // MaxAge indicates how long (in seconds) the results of a preflight request
// can be cached. // can be cached.
// Optional. Default value 0. // Optional. Default value 0.
MaxAge int MaxAge int `json:"max_age"`
} }
) )

View File

@ -18,11 +18,11 @@ type (
// CSRFConfig defines the config for CSRF middleware. // CSRFConfig defines the config for CSRF middleware.
CSRFConfig struct { CSRFConfig struct {
// Key to create CSRF token. // Key to create CSRF token.
Secret []byte Secret []byte `json:"secret"`
// Context key to store generated CSRF token into context. // Context key to store generated CSRF token into context.
// Optional. Default value "csrf". // Optional. Default value "csrf".
ContextKey string ContextKey string `json:"context_key"`
// Extractor is a function that extracts token from the request. // Extractor is a function that extracts token from the request.
// Optional. Default value CSRFTokenFromHeader(echo.HeaderXCSRFToken). // Optional. Default value CSRFTokenFromHeader(echo.HeaderXCSRFToken).
@ -30,27 +30,27 @@ type (
// Name of the CSRF cookie. This cookie will store CSRF token. // Name of the CSRF cookie. This cookie will store CSRF token.
// Optional. Default value "csrf". // Optional. Default value "csrf".
CookieName string CookieName string `json:"cookie_name"`
// Domain of the CSRF cookie. // Domain of the CSRF cookie.
// Optional. Default value none. // Optional. Default value none.
CookieDomain string CookieDomain string `json:"cookie_domain"`
// Path of the CSRF cookie. // Path of the CSRF cookie.
// Optional. Default value none. // Optional. Default value none.
CookiePath string CookiePath string `json:"cookie_path"`
// Expiration time of the CSRF cookie. // Expiration time of the CSRF cookie.
// Optional. Default value 24H. // Optional. Default value 24H.
CookieExpires time.Time CookieExpires time.Time `json:"cookie_expires"`
// Indicates if CSRF cookie is secure. // Indicates if CSRF cookie is secure.
CookieSecure bool CookieSecure bool `json:"cookie_secure"`
// Optional. Default value false. // Optional. Default value false.
// Indicates if CSRF cookie is HTTP only. // Indicates if CSRF cookie is HTTP only.
// Optional. Default value false. // Optional. Default value false.
CookieHTTPOnly bool CookieHTTPOnly bool `json:"cookie_http_only"`
} }
// CSRFTokenExtractor defines a function that takes `echo.Context` and returns // CSRFTokenExtractor defines a function that takes `echo.Context` and returns

View File

@ -14,15 +14,15 @@ type (
JWTConfig struct { JWTConfig struct {
// Signing key to validate token. // Signing key to validate token.
// Required. // Required.
SigningKey []byte SigningKey []byte `json:"signing_key"`
// Signing method, used to check token signing method. // Signing method, used to check token signing method.
// Optional. Default value HS256. // Optional. Default value HS256.
SigningMethod string SigningMethod string `json:"signing_method"`
// Context key to store user information from the token into context. // Context key to store user information from the token into context.
// Optional. Default value "user". // Optional. Default value "user".
ContextKey string ContextKey string `json:"context_key"`
// Extractor is a function that extracts token from the request. // Extractor is a function that extracts token from the request.
// Optional. Default value JWTFromHeader. // Optional. Default value JWTFromHeader.

View File

@ -39,7 +39,7 @@ type (
// Example "${remote_ip} ${status}" // Example "${remote_ip} ${status}"
// //
// Optional. Default value DefaultLoggerConfig.Format. // Optional. Default value DefaultLoggerConfig.Format.
Format string Format string `json:"format"`
// Output is a writer where logs are written. // Output is a writer where logs are written.
// Optional. Default value os.Stdout. // Optional. Default value os.Stdout.

View File

@ -13,16 +13,16 @@ type (
RecoverConfig struct { RecoverConfig struct {
// Size of the stack to be printed. // Size of the stack to be printed.
// Optional. Default value 4KB. // Optional. Default value 4KB.
StackSize int StackSize int `json:"stack_size"`
// DisableStackAll disables formatting stack traces of all other goroutines // DisableStackAll disables formatting stack traces of all other goroutines
// into buffer after the trace for the current goroutine. // into buffer after the trace for the current goroutine.
// Optional. Default value false. // Optional. Default value false.
DisableStackAll bool DisableStackAll bool `json:"disable_stack_all"`
// DisablePrintStack disables printing stack trace. // DisablePrintStack disables printing stack trace.
// Optional. Default value as false. // Optional. Default value as false.
DisablePrintStack bool DisablePrintStack bool `json:"disable_print_stack"`
} }
) )

View File

@ -12,12 +12,12 @@ type (
// XSSProtection provides protection against cross-site scripting attack (XSS) // XSSProtection provides protection against cross-site scripting attack (XSS)
// by setting the `X-XSS-Protection` header. // by setting the `X-XSS-Protection` header.
// Optional. Default value "1; mode=block". // Optional. Default value "1; mode=block".
XSSProtection string XSSProtection string `json:"xss_protection"`
// ContentTypeNosniff provides protection against overriding Content-Type // ContentTypeNosniff provides protection against overriding Content-Type
// header by setting the `X-Content-Type-Options` header. // header by setting the `X-Content-Type-Options` header.
// Optional. Default value "nosniff". // Optional. Default value "nosniff".
ContentTypeNosniff string ContentTypeNosniff string `json:"content_type_nosniff"`
// XFrameOptions can be used to indicate whether or not a browser should // XFrameOptions can be used to indicate whether or not a browser should
// be allowed to render a page in a <frame>, <iframe> or <object> . // 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. // `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. // `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. // `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 // HSTSMaxAge sets the `Strict-Transport-Security` header to indicate how
// long (in seconds) browsers should remember that this site is only to // long (in seconds) browsers should remember that this site is only to
// be accessed using HTTPS. This reduces your exposure to some SSL-stripping // be accessed using HTTPS. This reduces your exposure to some SSL-stripping
// man-in-the-middle (MITM) attacks. // man-in-the-middle (MITM) attacks.
// Optional. Default value 0. // Optional. Default value 0.
HSTSMaxAge int HSTSMaxAge int `json:"hsts_max_age"`
// HSTSExcludeSubdomains won't include subdomains tag in the `Strict Transport Security` // HSTSExcludeSubdomains won't include subdomains tag in the `Strict Transport Security`
// header, excluding all subdomains from security policy. It has no effect // header, excluding all subdomains from security policy. It has no effect
// unless HSTSMaxAge is set to a non-zero value. // unless HSTSMaxAge is set to a non-zero value.
// Optional. Default value false. // Optional. Default value false.
HSTSExcludeSubdomains bool HSTSExcludeSubdomains bool `json:"hsts_exclude_subdomains"`
// ContentSecurityPolicy sets the `Content-Security-Policy` header providing // ContentSecurityPolicy sets the `Content-Security-Policy` header providing
// security against cross-site scripting (XSS), clickjacking and other code // security against cross-site scripting (XSS), clickjacking and other code
// injection attacks resulting from execution of malicious content in the // injection attacks resulting from execution of malicious content in the
// trusted web page context. // trusted web page context.
// Optional. Default value "". // Optional. Default value "".
ContentSecurityPolicy string ContentSecurityPolicy string `json:"content_security_policy"`
} }
) )

View File

@ -9,7 +9,7 @@ type (
TrailingSlashConfig struct { TrailingSlashConfig struct {
// Status code to be used when redirecting the request. // Status code to be used when redirecting the request.
// Optional, but when provided the request is redirected using this code. // Optional, but when provided the request is redirected using this code.
RedirectCode int RedirectCode int `json:"redirect_code"`
} }
) )