Documentation ¶
Index ¶
- Constants
- Variables
- func CacheFetcher(config CacheFetcherConfig, client *cache.Client) pike.Middleware
- func CreateErrorHandler(client *cache.Client) pike.ErrorHandler
- func DirectorPicker(config DirectorPickerConfig, directors pike.Directors) pike.Middleware
- func Dispatcher(config DispatcherConfig, client *cache.Client) pike.Middleware
- func FreshChecker(config FreshCheckerConfig) pike.Middleware
- func HeaderSetter(config HeaderSetterConfig) pike.Middleware
- func Identifier(config IdentifierConfig, client *cache.Client) pike.Middleware
- func Initialization(config InitializationConfig) pike.Middleware
- func Logger(config LoggerConfig) pike.Middleware
- func Ping(config PingConfig) pike.Middleware
- func Proxy(config ProxyConfig) pike.Middleware
- func Recover(config RecoverConfig) pike.Middleware
- type CacheFetcherConfig
- type DirectorPickerConfig
- type DispatcherConfig
- type FreshCheckerConfig
- type HeaderSetterConfig
- type IdentifierConfig
- type InitializationConfig
- type LoggerConfig
- type PingConfig
- type ProxyConfig
- type ProxyTarget
- type RecoverConfig
Constants ¶
View Source
const (
// HitForPassTTL hit for pass的有效期
HitForPassTTL = 600
)
Variables ¶
View Source
var ( // ErrDirectorNotFound 未找到可用的director ErrDirectorNotFound = pike.NewHTTPError(http.StatusNotImplemented, "director not found") // ErrRequestStatusNotSet 未设置请求的status ErrRequestStatusNotSet = pike.NewHTTPError(http.StatusNotImplemented, "request status not set") // ErrIdentityNotSet 未设置Identity ErrIdentityNotSet = pike.NewHTTPError(http.StatusNotImplemented, "identity not set") // ErrResponseNotSet 未设置response ErrResponseNotSet = pike.NewHTTPError(http.StatusNotImplemented, "response not set") // ErrContentEncodingNotSupport 未支持此content encoding ErrContentEncodingNotSupport = pike.NewHTTPError(http.StatusNotImplemented, "content enconding not support") // ErrNoBackendAvaliable 没有可用的backend ErrNoBackendAvaliable = pike.NewHTTPError(http.StatusServiceUnavailable, "no backend avaliable") // ErrGatewayTimeout 网关超时 ErrGatewayTimeout = pike.NewHTTPError(http.StatusGatewayTimeout, "gateway timeout") // ErrTooManyRequest 太多的请求正在处理中 ErrTooManyRequest = pike.NewHTTPError(http.StatusTooManyRequests, "too many request is handling") )
View Source
var ( // DefaultRecoverConfig is the default Recover middleware config. DefaultRecoverConfig = RecoverConfig{ StackSize: 4 << 10, DisableStackAll: false, DisablePrintStack: false, } )
Functions ¶
func CacheFetcher ¶
func CacheFetcher(config CacheFetcherConfig, client *cache.Client) pike.Middleware
CacheFetcher 从缓存中获取数据
func CreateErrorHandler ¶
func CreateErrorHandler(client *cache.Client) pike.ErrorHandler
CreateErrorHandler 创建异常处理函数
func DirectorPicker ¶
func DirectorPicker(config DirectorPickerConfig, directors pike.Directors) pike.Middleware
DirectorPicker 根据请求的参数获取相应的director 判断director是否符合是顺序查询,因此需要将directors先根据优先级排好序
func Dispatcher ¶
func Dispatcher(config DispatcherConfig, client *cache.Client) pike.Middleware
Dispatcher 对响应数据做缓存,复制等处理
func FreshChecker ¶
func FreshChecker(config FreshCheckerConfig) pike.Middleware
FreshChecker 判断请求是否fresh(304)
func Identifier ¶
func Identifier(config IdentifierConfig, client *cache.Client) pike.Middleware
Identifier 对请求的参数校验,生成各类状态值
- 判断请求状态,生成status - 对于状态非Pass的请求,根据request url 生成identity
func Initialization ¶
func Initialization(config InitializationConfig) pike.Middleware
Initialization 相关一些初始化的操作
func Proxy ¶
func Proxy(config ProxyConfig) pike.Middleware
Proxy returns a Proxy middleware with config.
Types ¶
type DispatcherConfig ¶
type DispatcherConfig struct { // 压缩数据类型 CompressTypes []string // 最小压缩 CompressMinLength int // CompressLevel 数据压缩级别 CompressLevel int }
DispatcherConfig dipatcher的配置
type InitializationConfig ¶
InitializationConfig 初始化配置
type LoggerConfig ¶
LoggerConfig logger配置
type ProxyConfig ¶
type ProxyConfig struct { // Rewrites defines URL path rewrite rules. The values captured in asterisk can be // retrieved by index e.g. $1, $2 and so on. // Examples: // "/old": "/new", // "/api/*": "/$1", // "/js/*": "/public/javascripts/$1", // "/users/*/orders/*": "/user/$1/order/$2", Rewrites []string // ETag 是否生成ETag ETag bool // Timeout proxy的连接超时 Timeout time.Duration // contains filtered or unexported fields }
ProxyConfig defines the config for Proxy middleware.
type ProxyTarget ¶
ProxyTarget defines the upstream target.
type RecoverConfig ¶
type RecoverConfig struct { // Size of the stack to be printed. // Optional. Default value 4KB. StackSize int `yaml:"stack_size"` // DisableStackAll disables formatting stack traces of all other goroutines // into buffer after the trace for the current goroutine. // Optional. Default value false. DisableStackAll bool `yaml:"disable_stack_all"` // DisablePrintStack disables printing stack trace. // Optional. Default value as false. DisablePrintStack bool `yaml:"disable_print_stack"` }
RecoverConfig recover config
Click to show internal directories.
Click to hide internal directories.