Documentation ¶
Index ¶
- Variables
- func BasicAuth(fn fnValidator) yee.HandlerFunc
- func BasicAuthWithConfig(config BasicAuthConfig) yee.HandlerFunc
- func CSRF() yee.HandlerFunc
- func CSRFWithConfig(config CSRFConfig) yee.HandlerFunc
- 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 New(e *yee.Core) io.Closer
- func ProxyWithConfig(config ProxyConfig) 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
- func TraceWithConfig(config TraceConfig) yee.HandlerFunc
- type BasicAuthConfig
- type CORSConfig
- type CSRFConfig
- type GzipConfig
- type JWTErrorHandler
- type JWTSuccessHandler
- type JwtConfig
- type LoggerConfig
- type ProxyConfig
- type ProxyTarget
- type ProxyTargetHandler
- type RateLimitConfig
- type RequestIDConfig
- type SecureConfig
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
var CSRFDefaultConfig = CSRFConfig{ TokenLength: 16, TokenLookup: "header:" + yee.HeaderXCSRFToken, Key: "csrf", CookieName: "_csrf", CookieMaxAge: 28800, }
CSRFDefaultConfig is the default config of CSRF middleware
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, }, }
DefaultCORSConfig is the default config of CORS middleware
var DefaultGzipConfig = GzipConfig{Level: 1}
DefaultGzipConfig is the default config of gzip middleware
var DefaultJwtConfig = JwtConfig{ GetKey: "auth", SigningMethod: algorithmHS256, AuthScheme: "Bearer", TokenLookup: []string{yee.HeaderAuthorization}, Claims: jwt.MapClaims{}, }
DefaultJwtConfig is the default config of JWT middleware
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, }
DefaultLoggerConfig is default config of logger middleware
var DefaultRateLimit = RateLimitConfig{ Time: 1 * time.Second, Rate: 5, }
DefaultRateLimit is the default config of rateLimit middleware
var DefaultRequestIDConfig = RequestIDConfig{ // contains filtered or unexported fields }
DefaultRequestIDConfig is the default config of requestID middleware
var DefaultSecureConfig = SecureConfig{ XSSProtection: "1; mode=block", ContentTypeNosniff: "nosniff", XFrameOptions: "SAMEORIGIN", HSTSPreloadEnabled: false, }
DefaultSecureConfig is default config of secure middleware
Functions ¶
func BasicAuth ¶ added in v0.0.6
func BasicAuth(fn fnValidator) yee.HandlerFunc
BasicAuth is the default implementation BasicAuth middleware
func BasicAuthWithConfig ¶ added in v0.0.6
func BasicAuthWithConfig(config BasicAuthConfig) yee.HandlerFunc
BasicAuthWithConfig is the custom implementation BasicAuth middleware
func CSRF ¶ added in v0.1.2
func CSRF() yee.HandlerFunc
CSRF is the default implementation CSRF middleware
func CSRFWithConfig ¶ added in v0.0.6
func CSRFWithConfig(config CSRFConfig) yee.HandlerFunc
CSRFWithConfig is the custom implementation CSRF middleware
func CorsWithConfig ¶
func CorsWithConfig(config CORSConfig) yee.HandlerFunc
CorsWithConfig is the default implementation CORS middleware
func GzipWithConfig ¶
func GzipWithConfig(config GzipConfig) yee.HandlerFunc
GzipWithConfig is the custom implementation of gzip middleware
func JWTWithConfig ¶
func JWTWithConfig(config JwtConfig) yee.HandlerFunc
JWTWithConfig is the custom implementation CORS middleware
func LoggerWithConfig ¶
func LoggerWithConfig(config LoggerConfig) yee.HandlerFunc
LoggerWithConfig is custom implementation of logger middleware
func ProxyWithConfig ¶ added in v0.3.7
func ProxyWithConfig(config ProxyConfig) yee.HandlerFunc
func RateLimit ¶ added in v0.0.6
func RateLimit() yee.HandlerFunc
RateLimit is the default implementation of rateLimit middleware
func RateLimitWithConfig ¶ added in v0.0.6
func RateLimitWithConfig(config RateLimitConfig) yee.HandlerFunc
RateLimitWithConfig is the custom implementation of rateLimit middleware
func Recovery ¶
func Recovery() yee.HandlerFunc
Recovery is a recovery middleware when the program was panic it can recovery program and print stack info
func RequestID ¶ added in v0.0.6
func RequestID() yee.HandlerFunc
RequestID is the default implementation of requestID middleware
func RequestIDWithConfig ¶ added in v0.0.6
func RequestIDWithConfig(config RequestIDConfig) yee.HandlerFunc
RequestIDWithConfig is the custom implementation of requestID middleware
func SecureWithConfig ¶
func SecureWithConfig(config SecureConfig) yee.HandlerFunc
SecureWithConfig is custom implementation of secure middleware
func TraceWithConfig ¶ added in v0.3.4
func TraceWithConfig(config TraceConfig) yee.HandlerFunc
Types ¶
type BasicAuthConfig ¶ added in v0.0.6
type BasicAuthConfig struct { Validator fnValidator Realm string }
BasicAuthConfig defines the config of basicAuth middleware
type CORSConfig ¶
type CORSConfig struct { Origins []string AllowMethods []string AllowHeaders []string AllowCredentials bool ExposeHeaders []string MaxAge int }
CORSConfig defined the config of CORS middleware
type CSRFConfig ¶ added in v0.0.6
type CSRFConfig struct { TokenLength uint8 TokenLookup string Key string CookieName string CookieDomain string CookiePath string CookieMaxAge int CookieSecure bool CookieHTTPOnly bool }
CSRFConfig defines the config of CSRF middleware
type JWTErrorHandler ¶
JWTErrorHandler defines a function which is error for a valid token.
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 }
JwtConfig defines the config of JWT middleware
type LoggerConfig ¶
LoggerConfig defines config of logger middleware
type ProxyConfig ¶ added in v0.3.7
type ProxyConfig struct { BalanceType string Transport http.RoundTripper ModifyResponse func(*http.Response) error ProxyTarget ProxyTargetHandler }
type ProxyTarget ¶ added in v0.3.7
type ProxyTargetHandler ¶ added in v0.3.7
type ProxyTargetHandler interface {
MatchAlgorithm() ProxyTarget
}
type RateLimitConfig ¶ added in v0.0.6
type RateLimitConfig struct { Time time.Duration Rate int // contains filtered or unexported fields }
RateLimitConfig defines config of rateLimit middleware
type RequestIDConfig ¶ added in v0.0.6
type RequestIDConfig struct {
// contains filtered or unexported fields
}
RequestIDConfig defines config of requestID middleware
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"` }
SecureConfig defines config of secure middleware