Documentation
¶
Index ¶
- type AccessConfig
- type AccessPolicy
- type CachePolicy
- type ClientConfig
- type HeaderConfig
- type HeaderList
- func (this *HeaderList) AddHeader(header *HeaderConfig)
- func (this *HeaderList) AddIgnoreHeader(name string)
- func (this *HeaderList) AllHeaders() []*HeaderConfig
- func (this *HeaderList) AllIgnoreHeaders() []string
- func (this *HeaderList) ContainsHeader(name string) bool
- func (this *HeaderList) ContainsIgnoreHeader(name string) bool
- func (this *HeaderList) FindHeader(headerId string) *HeaderConfig
- func (this *HeaderList) FormatHeaders(formatter func(source string) string) []*HeaderConfig
- func (this *HeaderList) HasHeaders() bool
- func (this *HeaderList) RemoveHeader(headerId string)
- func (this *HeaderList) RemoveIgnoreHeader(name string)
- func (this *HeaderList) UpdateIgnoreHeader(oldName string, newName string)
- func (this *HeaderList) ValidateHeaders() error
- type HeaderListInterface
- type Pair
- type RequestCall
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessConfig ¶
type AccessConfig struct {
On bool `yaml:"on" json:"on"` // 是否开启
AllowOn bool `yaml:"allowOn" json:"allowOn"` // 白名单是否开启
DenyOn bool `yaml:"denyOn" json:"denyOn"` // 黑名单是否开启
Allow []*ClientConfig `yaml:"allow" json:"allow"` // 允许的IP
Deny []*ClientConfig `yaml:"deny" json:"deny"` // 禁止的IP
}
访问控制
type AccessPolicy ¶
type AccessPolicy struct {
// 流量控制
Traffic struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"total" json:"total"` // 总量控制
Second struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Duration int64 `yaml:"duration" json:"duration"` // 时间长度
FromTime int64 `yaml:"fromTime" json:"fromTime"` // 开始时间,也是结束时间
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"second" json:"second"`
Minute struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Duration int64 `yaml:"duration" json:"duration"` // 时间长度
FromTime int64 `yaml:"fromTime" json:"fromTime"` // 开始时间
ToTime int64 `yaml:"toTime" json:"toTime"` // 结束时间
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"minute" json:"minute"`
Hour struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Duration int64 `yaml:"duration" json:"duration"` // 时间长度
FromTime int64 `yaml:"fromTime" json:"fromTime"` // 开始时间
ToTime int64 `yaml:"toTime" json:"toTime"` // 结束时间
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"hour" json:"hour"`
Day struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Duration int64 `yaml:"duration" json:"duration"` // 时间长度
FromTime int64 `yaml:"fromTime" json:"fromTime"` // 开始时间
ToTime int64 `yaml:"toTime" json:"toTime"` // 结束时间
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"day" json:"day"`
Month struct {
On bool `yaml:"on" json:"on"` // 是否开启
Total int64 `yaml:"total" json:"total"` // 总量
Duration int64 `yaml:"duration" json:"duration"` // 时间长度
FromTime int64 `yaml:"fromTime" json:"fromTime"` // 开始时间
ToTime int64 `yaml:"toTime" json:"toTime"` // 结束时间
Used int64 `yaml:"used" json:"used"` // 已使用量
} `yaml:"month" json:"month"`
} `yaml:"traffic" json:"traffic"` // 流量控制
// 访问控制
Access AccessConfig `yaml:"access" json:"access"` // 访问控制
// contains filtered or unexported fields
}
API控制策略
func (*AccessPolicy) AllowTraffic ¶
func (this *AccessPolicy) AllowTraffic() (reason string, allowed bool)
检查流量
type CachePolicy ¶
type CachePolicy struct {
Filename string `yaml:"filename" json:"filename"` // 文件名
Id string `yaml:"id" json:"id"`
On bool `yaml:"on" json:"on"` // 是否开启 TODO
Name string `yaml:"name" json:"name"` // 名称
Key string `yaml:"key" json:"key"` // 每个缓存的Key规则,里面可以有变量
Capacity string `yaml:"capacity" json:"capacity"` // 最大内容容量
Life string `yaml:"life" json:"life"` // 时间
Status []int `yaml:"status" json:"status"` // 缓存的状态码列表
MaxSize string `yaml:"maxSize" json:"maxSize"` // 能够请求的最大尺寸
Type string `yaml:"type" json:"type"` // 类型
Options map[string]interface{} `yaml:"options" json:"options"` // 选项
// contains filtered or unexported fields
}
缓存策略配置
type ClientConfig ¶
type ClientConfig struct {
Id string `yaml:"id" json:"id"` // ID
On bool `yaml:"on" json:"on"` // 是否开启
IP string `yaml:"ip" json:"ip"` // IP
Description string `yaml:"description" json:"description"` // 描述
// contains filtered or unexported fields
}
客户端配置
type HeaderConfig ¶
type HeaderConfig struct {
On bool `yaml:"on" json:"on"` // 是否开启
Id string `yaml:"id" json:"id"` // ID
Name string `yaml:"name" json:"name"` // Name
Value string `yaml:"value" json:"value"` // Value
Always bool `yaml:"always" json:"always"` // 是否忽略状态码
Status []int `yaml:"status" json:"status"` // 支持的状态码
// contains filtered or unexported fields
}
头部信息定义
type HeaderList ¶
type HeaderList struct {
// 添加的Headers
Headers []*HeaderConfig `yaml:"headers" json:"headers"`
// 忽略的Headers
IgnoreHeaders []string `yaml:"ignoreHeaders" json:"ignoreHeaders"`
// contains filtered or unexported fields
}
HeaderList定义
func (*HeaderList) AddIgnoreHeader ¶
func (this *HeaderList) AddIgnoreHeader(name string)
添加IgnoreHeader
func (*HeaderList) AllIgnoreHeaders ¶
func (this *HeaderList) AllIgnoreHeaders() []string
取得所有的IgnoreHeader
func (*HeaderList) ContainsHeader ¶
func (this *HeaderList) ContainsHeader(name string) bool
判断是否包含Header
func (*HeaderList) ContainsIgnoreHeader ¶
func (this *HeaderList) ContainsIgnoreHeader(name string) bool
判断是否包含IgnoreHeader
func (*HeaderList) FindHeader ¶
func (this *HeaderList) FindHeader(headerId string) *HeaderConfig
查找Header
func (*HeaderList) FormatHeaders ¶
func (this *HeaderList) FormatHeaders(formatter func(source string) string) []*HeaderConfig
格式化Header
func (*HeaderList) HasHeaders ¶ added in v0.1.2
func (this *HeaderList) HasHeaders() bool
是否有Headers
func (*HeaderList) RemoveIgnoreHeader ¶
func (this *HeaderList) RemoveIgnoreHeader(name string)
移除IgnoreHeader
func (*HeaderList) UpdateIgnoreHeader ¶
func (this *HeaderList) UpdateIgnoreHeader(oldName string, newName string)
修改IgnoreHeader
type HeaderListInterface ¶
type HeaderListInterface interface {
// 校验
ValidateHeaders() error
// 取得所有的IgnoreHeader
AllIgnoreHeaders() []string
// 添加IgnoreHeader
AddIgnoreHeader(name string)
// 判断是否包含IgnoreHeader
ContainsIgnoreHeader(name string) bool
// 移除IgnoreHeader
RemoveIgnoreHeader(name string)
// 修改IgnoreHeader
UpdateIgnoreHeader(oldName string, newName string)
// 取得所有的Header
AllHeaders() []*HeaderConfig
// 添加Header
AddHeader(header *HeaderConfig)
// 判断是否包含Header
ContainsHeader(name string) bool
// 查找Header
FindHeader(headerId string) *HeaderConfig
// 移除Header
RemoveHeader(headerId string)
// 格式化Headers
FormatHeaders(formatter func(source string) string) []*HeaderConfig
}
HeaderList相关操作接口
type Pair ¶ added in v0.1.2
type Pair struct {
Name string `yaml:"name" json:"name"` // 变量名
Value string `yaml:"value" json:"value"` // 变量值
}
键值对
type RequestCall ¶ added in v0.1.2
type RequestCall struct {
Formatter func(source string) string
Request *http.Request
ResponseCallbacks []func(resp http.ResponseWriter)
Options maps.Map
}
请求调用
func (*RequestCall) AddResponseCall ¶ added in v0.1.2
func (this *RequestCall) AddResponseCall(callback func(resp http.ResponseWriter))
添加响应回调
func (*RequestCall) CallResponseCallbacks ¶ added in v0.1.2
func (this *RequestCall) CallResponseCallbacks(resp http.ResponseWriter)
执行响应回调
Click to show internal directories.
Click to hide internal directories.