Documentation ¶
Index ¶
Constants ¶
const ( // FilterHTTPAccess access log filter FilterHTTPAccess = "HTTP-ACCESS" // FilterHeader header filter FilterHeader = "HEAD" // 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-BREAKE" // FilterValidation validation request filter FilterValidation = "VALIDATION" )
const (
// RateBase base rate
RateBase = 100
)
const (
// TimerPrefix timer prefix
TimerPrefix = "Circuit-"
)
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 ( // MergeContentType merge operation using content-type MergeContentType = "application/json; charset=utf-8" // MergeRemoveHeaders merge operation need to remove headers MergeRemoveHeaders = []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) 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 CircuitBreakeFilter ¶
type CircuitBreakeFilter struct {
filter.BaseFilter
}
CircuitBreakeFilter CircuitBreakeFilter
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 HeadersFilter ¶
type HeadersFilter struct {
filter.BaseFilter
}
HeadersFilter HeadersFilter
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager support runtime remote interface
func (*Manager) AddAnalysisPoint ¶
func (m *Manager) AddAnalysisPoint(req model.AddAnalysisPointReq, rsp *model.AddAnalysisPointRsp) error
AddAnalysisPoint add a point to analysis
func (*Manager) GetAnalysisPoint ¶
func (m *Manager) GetAnalysisPoint(req model.GetAnalysisPointReq, rsp *model.GetAnalysisPointRsp) error
GetAnalysisPoint return analysis point data
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) 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 (v 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) Name ¶
func (f XForwardForFilter) Name() string
Name return name of this filter