Documentation ¶
Index ¶
- Constants
- Variables
- func GetRealClientIP(ctx *fasthttp.RequestCtx) string
- type AccessFilter
- type AnalysisFilter
- type BlackListFilter
- type CachingFilter
- type Cfg
- type CircuitBreakeFilter
- func (f *CircuitBreakeFilter) Init(cfg string) error
- func (f *CircuitBreakeFilter) Name() string
- func (f *CircuitBreakeFilter) Post(c filter.Context) (statusCode int, err error)
- func (f *CircuitBreakeFilter) PostErr(c filter.Context)
- func (f *CircuitBreakeFilter) Pre(c filter.Context) (statusCode int, err error)
- type FilterSpec
- type HeadersFilter
- type Option
- type Proxy
- type RateLimitingFilter
- type ValidationFilter
- type WhiteListFilter
- type XForwardForFilter
Constants ¶
const ( // FilterHTTPAccess access log filter FilterHTTPAccess = "HTTP-ACCESS" // FilterHeader header filter FilterHeader = "HEADER" // process header fiter // FilterXForward xforward fiter FilterXForward = "XFORWARD" // FilterBlackList blacklist filter FilterBlackList = "BLACKLIST" // FilterWhiteList whitelist filter FilterWhiteList = "WHITELIST" // FilterAnalysis analysis filter FilterAnalysis = "ANALYSIS" // FilterRateLimiting limit filter FilterRateLimiting = "RATE-LIMITING" // FilterCircuitBreake circuit breake filter FilterCircuitBreake = "CIRCUIT-BREAKER" // FilterValidation validation request filter FilterValidation = "VALIDATION" // FilterCaching access log filter FilterCaching = "CACHING" )
const (
// RateBase base rate
RateBase = 100
)
Variables ¶
var ( // ErrCircuitClose server is in circuit close ErrCircuitClose = errors.New("server is in circuit close") // ErrCircuitHalf server is in circuit half ErrCircuitHalf = errors.New("server is in circuit half") // ErrCircuitHalfLimited server is in circuit half, traffic limit ErrCircuitHalfLimited = errors.New("server is in circuit half, traffic limit") )
var ( // ErrPrefixRequestCancel user cancel request error ErrPrefixRequestCancel = "request canceled" // ErrNoServer no server ErrNoServer = errors.New("has no server") // ErrRewriteNotMatch rewrite not match request url ErrRewriteNotMatch = errors.New("rewrite not match request url") )
var ( // MultiResultsContentType merge operation using content-type MultiResultsContentType = "application/json; charset=utf-8" // MultiResultsRemoveHeaders merge operation need to remove headers MultiResultsRemoveHeaders = []string{ "Content-Length", "Content-Type", "Date", } )
var ( // ErrBlacklist target ip in black list ErrBlacklist = errors.New("Err, target ip in black list") )
var ( // ErrTraffixLimited traffic limit ErrTraffixLimited = errors.New("traffic limit") )
var ( // ErrUnknownFilter unknown filter error ErrUnknownFilter = errors.New("unknow filter") )
var ( // ErrValidationFailure validation failure ErrValidationFailure = errors.New("request validation failure") )
var ( // ErrWhitelist target ip not in in white list ErrWhitelist = errors.New("Err, target ip not in in white list") )
Functions ¶
func GetRealClientIP ¶
func GetRealClientIP(ctx *fasthttp.RequestCtx) string
GetRealClientIP get read client ip
Types ¶
type AccessFilter ¶
type AccessFilter struct {
filter.BaseFilter
}
AccessFilter record the http access log log format: $remoteip "$method $path" $code "$agent" $svr $cost
type AnalysisFilter ¶
type AnalysisFilter struct {
filter.BaseFilter
}
AnalysisFilter analysis filter
func (*AnalysisFilter) Name ¶
func (f *AnalysisFilter) Name() string
Name return name of this filter
func (*AnalysisFilter) Post ¶
func (f *AnalysisFilter) Post(c filter.Context) (statusCode int, err error)
Post execute after proxy
func (*AnalysisFilter) PostErr ¶
func (f *AnalysisFilter) PostErr(c filter.Context)
PostErr execute proxy has errors
type BlackListFilter ¶
type BlackListFilter struct {
filter.BaseFilter
}
BlackListFilter blacklist filter
func (*BlackListFilter) Name ¶
func (f *BlackListFilter) Name() string
Name return name of this filter
type CachingFilter ¶
type CachingFilter struct { filter.BaseFilter // contains filtered or unexported fields }
CachingFilter cache api result
type Cfg ¶
type Cfg struct { Addr string AddrRPC string AddrStore string AddrPPROF string Namespace string TTLProxy int64 Filers []*FilterSpec Option *Option }
Cfg proxy config
type CircuitBreakeFilter ¶
type CircuitBreakeFilter struct {
filter.BaseFilter
}
CircuitBreakeFilter CircuitBreakeFilter
func (*CircuitBreakeFilter) Init ¶
func (f *CircuitBreakeFilter) Init(cfg string) error
Init init filter
func (*CircuitBreakeFilter) Name ¶
func (f *CircuitBreakeFilter) Name() string
Name return name of this filter
func (*CircuitBreakeFilter) Post ¶
func (f *CircuitBreakeFilter) Post(c filter.Context) (statusCode int, err error)
Post execute after proxy
func (*CircuitBreakeFilter) PostErr ¶
func (f *CircuitBreakeFilter) PostErr(c filter.Context)
PostErr execute proxy has errors
type FilterSpec ¶
type FilterSpec struct { Name string `json:"name"` External bool `json:"external,omitempty"` ExternalPluginFile string `json:"externalPluginFile,omitempty"` ExternalCfg string `json:"externalCfg,omitempty"` }
FilterSpec filter spec
func ParseFilter ¶
func ParseFilter(filter string) (*FilterSpec, error)
ParseFilter returns a filter
type HeadersFilter ¶
type HeadersFilter struct {
filter.BaseFilter
}
HeadersFilter HeadersFilter
type Option ¶
type Option struct { LimitCountDispatchWorker uint64 LimitCountCopyWorker uint64 LimitCountHeathCheckWorker int LimitCountConn int LimitIntervalHeathCheck time.Duration LimitDurationConnKeepalive time.Duration LimitDurationConnIdle time.Duration LimitTimeoutWrite time.Duration LimitTimeoutRead time.Duration LimitBufferRead int LimitBufferWrite int LimitBytesBody int LimitBytesCaching uint64 }
Option proxy option
type Proxy ¶
Proxy Proxy
func (*Proxy) ReverseProxyHandler ¶
func (p *Proxy) ReverseProxyHandler(ctx *fasthttp.RequestCtx)
ReverseProxyHandler http reverse handler
type RateLimitingFilter ¶
type RateLimitingFilter struct {
filter.BaseFilter
}
RateLimitingFilter RateLimitingFilter
func (*RateLimitingFilter) Init ¶
func (f *RateLimitingFilter) Init(cfg string) error
Init init filter
func (*RateLimitingFilter) Name ¶
func (f *RateLimitingFilter) Name() string
Name return name of this filter
type ValidationFilter ¶
type ValidationFilter struct {
filter.BaseFilter
}
ValidationFilter validation request
func (*ValidationFilter) Name ¶
func (f *ValidationFilter) Name() string
Name return name of this filter
type WhiteListFilter ¶
type WhiteListFilter struct {
filter.BaseFilter
}
WhiteListFilter whitelist filter
func (*WhiteListFilter) Name ¶
func (f *WhiteListFilter) Name() string
Name return name of this filter
type XForwardForFilter ¶
type XForwardForFilter struct {
filter.BaseFilter
}
XForwardForFilter XForwardForFilter
func (*XForwardForFilter) Init ¶
func (f *XForwardForFilter) Init(cfg string) error
Init init filter
func (*XForwardForFilter) Name ¶
func (f *XForwardForFilter) Name() string
Name return name of this filter
Source Files ¶
- cfg.go
- checker.go
- dispatcher.go
- dispatcher_meta.go
- factory.go
- filter.go
- filter_access.go
- filter_analysis.go
- filter_blacklist.go
- filter_caching.go
- filter_circuit_breaker.go
- filter_headers.go
- filter_rate_limiting.go
- filter_validation.go
- filter_whitelist.go
- filter_xforwardfor.go
- io.go
- ip.go
- multi.go
- pool.go
- proxy.go
- render.go
- runtime.go