diff --git a/middleware/basic_auth.go b/middleware/basic_auth.go index 12f102e3..bb083905 100644 --- a/middleware/basic_auth.go +++ b/middleware/basic_auth.go @@ -9,7 +9,7 @@ import ( type ( // BasicAuthConfig defines the config for HTTP basic auth middleware. BasicAuthConfig struct { - // Validator is the function to validate basic auth credentials. + // Validator is a function to validate basic auth credentials. Validator BasicAuthValidator } diff --git a/middleware/body_limit.go b/middleware/body_limit.go index 9ead468f..f09aac31 100644 --- a/middleware/body_limit.go +++ b/middleware/body_limit.go @@ -13,7 +13,7 @@ import ( type ( // BodyLimitConfig defines the config for body limit middleware. BodyLimitConfig struct { - // Limit is the maximum allowed size for a request body, it can be specified + // Maximum allowed size for a request body, it can be specified // as `4x` or `4xB`, where x is one of the multiple from K, M, G, T or P. Limit string `json:"limit"` limit int64 diff --git a/middleware/compress.go b/middleware/compress.go index 164ca36c..83d0b2f5 100644 --- a/middleware/compress.go +++ b/middleware/compress.go @@ -15,8 +15,8 @@ import ( type ( // GzipConfig defines the config for gzip middleware. GzipConfig struct { - // Level is the gzip level. - // Optional, with default value as -1. + // Gzip compression level. + // Optional. Default value -1. Level int } diff --git a/middleware/cors.go b/middleware/cors.go index d6724062..3cf0d40e 100644 --- a/middleware/cors.go +++ b/middleware/cors.go @@ -12,34 +12,34 @@ type ( // CORSConfig defines the config for CORS middleware. CORSConfig struct { // AllowOrigin defines a list of origins that may access the resource. - // Optional, with default value as []string{"*"}. + // Optional. Default value []string{"*"}. AllowOrigins []string // AllowMethods defines a list methods allowed when accessing the resource. // This is used in response to a preflight request. - // Optional, with default value as `DefaultCORSConfig.AllowMethods`. + // Optional. Default value DefaultCORSConfig.AllowMethods. AllowMethods []string // AllowHeaders defines a list of request headers that can be used when // making the actual request. This in response to a preflight request. - // Optional, with default value as []string{}. + // Optional. Default value []string{}. AllowHeaders []string // 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, with default value as false. + // Optional. Default value false. AllowCredentials bool // ExposeHeaders defines a whitelist headers that clients are allowed to // access. - // Optional, with default value as []string{}. + // Optional. Default value []string{}. ExposeHeaders []string // MaxAge indicates how long (in seconds) the results of a preflight request // can be cached. - // Optional, with default value as 0. + // Optional. Default value 0. MaxAge int } ) diff --git a/middleware/jwt.go b/middleware/jwt.go index 7a792e20..2ec9fd1c 100644 --- a/middleware/jwt.go +++ b/middleware/jwt.go @@ -11,21 +11,20 @@ import ( type ( // JWTConfig defines the config for JWT auth middleware. JWTConfig struct { - // SigningKey is the key to validate token. + // Signing key to validate token. // Required. SigningKey []byte - // SigningMethod is used to check token signing method. - // Optional, with default value as `HS256`. + // Signing method, used to check token signing method. + // Optional. Default value HS256. SigningMethod string - // ContextKey is the key to be used for storing user information from the - // token into context. - // Optional, with default value as `user`. + // Context key to store user information from the token into context. + // Optional. Default value "user". ContextKey string // Extractor is a function that extracts token from the request. - // Optional, with default values as `JWTFromHeader`. + // Optional. Default value JWTFromHeader. Extractor JWTExtractor } diff --git a/middleware/logger.go b/middleware/logger.go index 0fecd5b8..c22e40c1 100644 --- a/middleware/logger.go +++ b/middleware/logger.go @@ -19,7 +19,7 @@ import ( type ( // LoggerConfig defines the config for logger middleware. LoggerConfig struct { - // Format is the log format which can be constructed using the following tags: + // Log format which can be constructed using the following tags: // // - time_rfc3339 // - id (Request ID - Not implemented) @@ -38,11 +38,11 @@ type ( // // Example "${remote_ip} ${status}" // - // Optional, with default value as `DefaultLoggerConfig.Format`. + // Optional. Default value DefaultLoggerConfig.Format. Format string - // Output is the writer where logs are written. - // Optional with default value as os.Stdout. + // Output is a writer where logs are written. + // Optional. Default value os.Stdout. Output io.Writer template *fasttemplate.Template diff --git a/middleware/method_override.go b/middleware/method_override.go index f876f01a..0b49e5ca 100644 --- a/middleware/method_override.go +++ b/middleware/method_override.go @@ -8,11 +8,11 @@ type ( // MethodOverrideConfig defines the config for method override middleware. MethodOverrideConfig struct { // Getter is a function that gets overridden method from the request. + // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride). Getter MethodOverrideGetter } // MethodOverrideGetter is a function that gets overridden method from the request - // Optional, with default values as `MethodFromHeader(echo.HeaderXHTTPMethodOverride)`. MethodOverrideGetter func(echo.Context) string ) diff --git a/middleware/recover.go b/middleware/recover.go index fa336ff5..0c250e4e 100644 --- a/middleware/recover.go +++ b/middleware/recover.go @@ -11,17 +11,17 @@ import ( type ( // RecoverConfig defines the config for recover middleware. RecoverConfig struct { - // StackSize is the stack size to be printed. - // Optional, with default value as 4 KB. + // Size of the stack to be printed. + // Optional. Default value 4KB. StackSize int // DisableStackAll disables formatting stack traces of all other goroutines // into buffer after the trace for the current goroutine. - // Optional, with default value as false. + // Optional. Default value false. DisableStackAll bool // DisablePrintStack disables printing stack trace. - // Optional, with default value as false. + // Optional. Default value as false. DisablePrintStack bool } ) diff --git a/middleware/secure.go b/middleware/secure.go index 459a15f7..1702595d 100644 --- a/middleware/secure.go +++ b/middleware/secure.go @@ -11,12 +11,12 @@ type ( SecureConfig struct { // XSSProtection provides protection against cross-site scripting attack (XSS) // by setting the `X-XSS-Protection` header. - // Optional, with default value as `1; mode=block`. + // Optional. Default value "1; mode=block". XSSProtection string // ContentTypeNosniff provides protection against overriding Content-Type // header by setting the `X-Content-Type-Options` header. - // Optional, with default value as "nosniff". + // Optional. Default value "nosniff". ContentTypeNosniff string // XFrameOptions can be used to indicate whether or not a browser should @@ -24,7 +24,7 @@ type ( // Sites can use this to avoid clickjacking attacks, by ensuring that their // content is not embedded into other sites.provides protection against // clickjacking. - // Optional, with default value as "SAMEORIGIN". + // Optional. Default value "SAMEORIGIN". // Possible values: // `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. @@ -35,20 +35,20 @@ type ( // 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, with default value as 0. + // Optional. Default value 0. HSTSMaxAge int // 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, with default value as false. + // Optional. Default value false. HSTSExcludeSubdomains bool // 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, with default value as "". + // Optional. Default value "". ContentSecurityPolicy string } ) diff --git a/middleware/slash.go b/middleware/slash.go index 67c6bcde..621fa5b6 100644 --- a/middleware/slash.go +++ b/middleware/slash.go @@ -7,7 +7,7 @@ import ( type ( // TrailingSlashConfig defines the config for TrailingSlash middleware. TrailingSlashConfig struct { - // RedirectCode is the status code 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. RedirectCode int } diff --git a/middleware/static.go b/middleware/static.go index 05e9e625..db141fa8 100644 --- a/middleware/static.go +++ b/middleware/static.go @@ -12,17 +12,16 @@ import ( type ( // StaticConfig defines the config for static middleware. StaticConfig struct { - // Root is the directory from where the static content is served. + // Root directory from where the static content is served. // Required. Root string `json:"root"` - // Index is the list of index files to be searched and used when serving - // a directory. - // Optional, with default value as []string{"index.html"}. - Index []string `json:"index"` + // Index file for serving a directory. + // Optional. Default value "index.html". + Index string `json:"index"` - // Browse is a flag to enable/disable directory browsing. - // Optional, with default value as false. + // Enable/disable directory browsing. + // Optional. Default value false. Browse bool `json:"browse"` } ) @@ -30,7 +29,7 @@ type ( var ( // DefaultStaticConfig is the default static middleware config. DefaultStaticConfig = StaticConfig{ - Index: []string{"index.html"}, + Index: "index.html", Browse: false, } ) @@ -47,7 +46,7 @@ func Static(root string) echo.MiddlewareFunc { // See `Static()`. func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc { // Defaults - if config.Index == nil { + if config.Index == "" { config.Index = DefaultStaticConfig.Index } @@ -77,8 +76,7 @@ func StaticWithConfig(config StaticConfig) echo.MiddlewareFunc { d := f // Index file - // TODO: search all files - file = path.Join(file, config.Index[0]) + file = path.Join(file, config.Index) f, err = fs.Open(file) if err == nil { // Index file