Documentation ¶
Index ¶
- Constants
- Variables
- func Cors() yee.HandlerFunc
- func CorsWithConfig(config CORSConfig) yee.HandlerFunc
- func Gzip() yee.HandlerFunc
- func GzipWithConfig(config GzipConfig) yee.HandlerFunc
- func JWTWithConfig(config JwtConfig) yee.HandlerFunc
- func Logger() yee.HandlerFunc
- func LoggerWithConfig(config LoggerConfig) yee.HandlerFunc
- func Recovery() yee.HandlerFunc
- func Secure() yee.HandlerFunc
- func SecureWithConfig(config SecureConfig) yee.HandlerFunc
- type CORSConfig
- type GzipConfig
- type JWTErrorHandler
- type JwtConfig
- type LoggerConfig
- type SecureConfig
Constants ¶
View Source
const (
AlgorithmHS256 = "HS256"
)
Variables ¶
View Source
var DefaultCORSConfig = CORSConfig{ Origins: []string{"*"}, AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete, http.MethodPatch, http.MethodHead, http.MethodOptions, http.MethodConnect, http.MethodTrace}, }
View Source
var DefaultGzipConfig = GzipConfig{Level: 1}
View Source
var DefaultJwtConfig = JwtConfig{ GetKey: "auth", SigningMethod: AlgorithmHS256, AuthScheme: "Bearer", TokenLookup: "header:" + yee.HeaderAuthorization, Claims: jwt.MapClaims{}, }
View Source
var DefaultLoggerConfig = LoggerConfig{ Format: `"url":"${url}" "method":"${method}" "status":${status} "protocol":"${protocol}" "remote_ip":"${remote_ip}" "bytes_in": "${bytes_in} bytes" "bytes_out": "${bytes_out} bytes"`, Level: 3, IsLogger: true, }
View Source
var DefaultSecureConfig = SecureConfig{ XSSProtection: "1; mode=block", ContentTypeNosniff: "nosniff", XFrameOptions: "SAMEORIGIN", HSTSPreloadEnabled: false, }
Functions ¶
func Cors ¶
func Cors() yee.HandlerFunc
func CorsWithConfig ¶
func CorsWithConfig(config CORSConfig) yee.HandlerFunc
func Gzip ¶
func Gzip() yee.HandlerFunc
func GzipWithConfig ¶
func GzipWithConfig(config GzipConfig) yee.HandlerFunc
func JWTWithConfig ¶
func JWTWithConfig(config JwtConfig) yee.HandlerFunc
func Logger ¶
func Logger() yee.HandlerFunc
func LoggerWithConfig ¶
func LoggerWithConfig(config LoggerConfig) yee.HandlerFunc
func Recovery ¶
func Recovery() yee.HandlerFunc
func Secure ¶
func Secure() yee.HandlerFunc
func SecureWithConfig ¶
func SecureWithConfig(config SecureConfig) yee.HandlerFunc
Types ¶
type CORSConfig ¶
type GzipConfig ¶
type GzipConfig struct {
Level int
}
type JWTErrorHandler ¶
type JwtConfig ¶
type JwtConfig struct { GetKey string AuthScheme string SigningKey interface{} SigningMethod string TokenLookup string Claims jwt.Claims ErrorHandler JWTErrorHandler // contains filtered or unexported fields }
type LoggerConfig ¶
type SecureConfig ¶
type SecureConfig struct { XSSProtection string `yaml:"xss_protection"` ContentTypeNosniff string `yaml:"content_type_nosniff"` XFrameOptions string `yaml:"x_frame_options"` HSTSMaxAge int `yaml:"hsts_max_age"` HSTSExcludeSubdomains bool `yaml:"hsts_exclude_subdomains"` ContentSecurityPolicy string `yaml:"content_security_policy"` CSPReportOnly bool `yaml:"csp_report_only"` HSTSPreloadEnabled bool `yaml:"hsts_preload_enabled"` ReferrerPolicy string `yaml:"referrer_policy"` }
Click to show internal directories.
Click to hide internal directories.