Documentation ¶
Index ¶
- Constants
- Variables
- func BasicAuth(fn fnValidator) yee.HandlerFunc
- func BasicAuthWithConfig(config BasicAuthConfig) yee.HandlerFunc
- func CSRFWithConfig(config CSRFConfig) yee.HandlerFunc
- func Cors() yee.HandlerFunc
- func CorsWithConfig(config CORSConfig) yee.HandlerFunc
- func Csrf() 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 RateLimit() yee.HandlerFunc
- func RateLimitWithConfig(config RateLimitConfig) yee.HandlerFunc
- func Recovery() yee.HandlerFunc
- func RequestID() yee.HandlerFunc
- func RequestIDWithConfig(config RequestIDConfig) yee.HandlerFunc
- func Secure() yee.HandlerFunc
- func SecureWithConfig(config SecureConfig) yee.HandlerFunc
- type BasicAuthConfig
- type CORSConfig
- type CSRFConfig
- type GzipConfig
- type JWTErrorHandler
- type JWTSuccessHandler
- type JwtConfig
- type LoggerConfig
- type RateLimitConfig
- type RequestIDConfig
- type SecureConfig
Constants ¶
View Source
const (
AlgorithmHS256 = "HS256"
)
Variables ¶
View Source
var CSRFDefaultConfig = CSRFConfig{ TokenLength: 16, TokenLookup: "header:" + yee.HeaderXCSRFToken, Key: "csrf", CookieName: "_csrf", CookieMaxAge: 28800, }
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 DefaultRateLimit = RateLimitConfig{ Time: 1 * time.Second, Rate: 5, }
View Source
var DefaultRequestIDConfig = RequestIDConfig{ // contains filtered or unexported fields }
View Source
var DefaultSecureConfig = SecureConfig{ XSSProtection: "1; mode=block", ContentTypeNosniff: "nosniff", XFrameOptions: "SAMEORIGIN", HSTSPreloadEnabled: false, }
Functions ¶
func BasicAuth ¶ added in v0.0.6
func BasicAuth(fn fnValidator) yee.HandlerFunc
func BasicAuthWithConfig ¶ added in v0.0.6
func BasicAuthWithConfig(config BasicAuthConfig) yee.HandlerFunc
func CSRFWithConfig ¶ added in v0.0.6
func CSRFWithConfig(config CSRFConfig) yee.HandlerFunc
func Cors ¶
func Cors() yee.HandlerFunc
func CorsWithConfig ¶
func CorsWithConfig(config CORSConfig) yee.HandlerFunc
func Csrf ¶ added in v0.0.6
func Csrf() 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 RateLimit ¶ added in v0.0.6
func RateLimit() yee.HandlerFunc
func RateLimitWithConfig ¶ added in v0.0.6
func RateLimitWithConfig(config RateLimitConfig) yee.HandlerFunc
func Recovery ¶
func Recovery() yee.HandlerFunc
func RequestID ¶ added in v0.0.6
func RequestID() yee.HandlerFunc
func RequestIDWithConfig ¶ added in v0.0.6
func RequestIDWithConfig(config RequestIDConfig) yee.HandlerFunc
func Secure ¶
func Secure() yee.HandlerFunc
func SecureWithConfig ¶
func SecureWithConfig(config SecureConfig) yee.HandlerFunc
Types ¶
type BasicAuthConfig ¶ added in v0.0.6
type BasicAuthConfig struct { Validator fnValidator Realm string }
type CORSConfig ¶
type CSRFConfig ¶ added in v0.0.6
type GzipConfig ¶
type GzipConfig struct {
Level int
}
type JWTErrorHandler ¶
type JWTSuccessHandler ¶ added in v0.0.8
JWTSuccessHandler defines a function which is executed for a valid token.
type JwtConfig ¶
type JwtConfig struct { GetKey string AuthScheme string SigningKey interface{} SigningMethod string TokenLookup string Claims jwt.Claims ErrorHandler JWTErrorHandler SuccessHandler JWTSuccessHandler // contains filtered or unexported fields }
type LoggerConfig ¶
type RateLimitConfig ¶ added in v0.0.6
type RequestIDConfig ¶ added in v0.0.6
type RequestIDConfig struct {
// contains filtered or unexported fields
}
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.