conf

package
v2.1.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAdminConfig

func ParseAdminConfig()

读入管理员配置信息

func ParseGatewayInfo

func ParseGatewayInfo(path string) map[string]*GatewayInfo

读入网关信息

func WriteConfigToFile

func WriteConfigToFile(path string, content []byte) bool

将内容写入文件中

Types

type Api

type Api struct {
	ApiList []*ApiInfo `json:"apis" yaml:"apis"`
}

type ApiInfo

type ApiInfo struct {
	ApiID          int              `json:"apiID" yaml:"api_id"`
	ApiName        string           `json:"apiName" yaml:"api_name"`
	GroupID        int              `json:"groupID" yaml:"group_id"`
	RequestURL     string           `json:"requestURL" yaml:"request_url"`
	RequestMethod  []string         `json:"requestMethod" yaml:"request_method"`
	BackendID      int              `json:"backendID" yaml:"backend_id"`
	ProxyURL       string           `json:"proxyURL" yaml:"proxy_url"`
	ProxyMethod    string           `json:"proxyMethod" yaml:"proxy_method"`
	IsRaw          bool             `json:"isRaw" yaml:"is_raw"`
	ProxyParams    []*Param         `json:"proxyParams" yaml:"proxy_params"`
	ConstantParams []*ConstantParam `json:"constantParams" yaml:"constant_params"`
	Follow         bool             `json:"follow" yaml:"follow"`
	UpdateTime     string           `json:"updateTime" yaml:"update_time"`
	CreateTime     string           `json:"createTime" yaml:"createTime"`
}

func ParseApiInfo

func ParseApiInfo(path string) ([]*ApiInfo, map[int]*ApiInfo, []map[string]interface{}, int)

读入接口信息

type ApiSlice

type ApiSlice []map[string]interface{}

func (ApiSlice) Len

func (a ApiSlice) Len() int

func (ApiSlice) Less

func (a ApiSlice) Less(i, j int) bool

func (ApiSlice) Swap

func (a ApiSlice) Swap(i, j int)

type Backend

type Backend struct {
	BackendList []*BackendInfo `json:"backend" yaml:"backend"`
}

type BackendInfo

type BackendInfo struct {
	BackendID   int    `json:"backendID" yaml:"backend_id"`
	BackendName string `json:"backendName" yaml:"backend_name"`
	BackendPath string `json:"backendPath" yaml:"backend_path"`
}

func ParseBackendInfo

func ParseBackendInfo(path string) ([]*BackendInfo, map[int]*BackendInfo)

读入后端信息

type ConstantParam

type ConstantParam struct {
	Position string `json:"position" yaml:"position"`
	Key      string `json:"key" yaml:"key"`
	Value    string `json:"value" yaml:"value"`
}

type GatewayInfo

type GatewayInfo struct {
	GatewayName      string   `json:"gatewayName" yaml:"gateway_name"`
	GatewayAlias     string   `json:"gatewayAlias" yaml:"gateway_alias"`
	GatewayStatus    string   `json:"gatewayStatus" yaml:"gateway_status"`
	ApiConfPath      string   `json:"apiConfPath" yaml:"api_conf_path"`
	ApiGroupConfPath string   `json:"apiGroupConfPath" yaml:"api_group_conf_path"`
	StrategyConfPath string   `json:"strategyConfPath" yaml:"strategy_conf_path"`
	BackendConfPath  string   `json:"backendConfPath" yaml:"backend_conf_path"`
	IPLimitType      string   `json:"ipLimitType,omitempty" yaml:"ip_limit_type,omitempty"`
	IPWhiteList      []string `json:"ipWhiteList,omitempty" yaml:"ip_white_list,omitempty"`
	IPBlackList      []string `json:"ipBlackList,omitempty" yaml:"ip_black_list,omitempty"`
	UpdateTime       string   `json:"updateTime,omitempty" yaml:"update_time,omitempty"`
	CreateTime       string   `json:"createTime,omitempty" yaml:"create_time,omitempty"`
}

type GatewaySlice

type GatewaySlice []map[string]interface{}

按照 Person.Age 从大到小排序

func (GatewaySlice) Len

func (a GatewaySlice) Len() int

func (GatewaySlice) Less

func (a GatewaySlice) Less(i, j int) bool

func (GatewaySlice) Swap

func (a GatewaySlice) Swap(i, j int)

type GlobalConfig

type GlobalConfig struct {
	Host            string `json:"host" yaml:"host"`
	Port            string `json:"port" yaml:"port"`
	GatewayConfPath string `json:"gatewayConfPath" yaml:"gateway_conf_path"`
	LoginName       string `json:"loginName" yaml:"login_name"`
	LoginPassword   string `json:"loginPassword" yaml:"login_password"`
}
var GlobalConf GlobalConfig

type Group

type Group struct {
	GroupList          []*GroupInfo `json:"group" yaml:"group"`
	CancelDefaultGroup bool         `json:"cancel_default_group" yaml:"cancel_default_group"`
}

type GroupInfo

type GroupInfo struct {
	GroupID   int    `json:"groupID" yaml:"group_id"`
	GroupName string `json:"groupName" yaml:"group_name"`
}

func ParseApiGroupInfo

func ParseApiGroupInfo(path string) ([]*GroupInfo, map[int]*GroupInfo, bool)

读入后端信息

type GroupSlice

type GroupSlice []*GroupInfo

按照 Person.Age 从大到小排序

func (GroupSlice) Len

func (a GroupSlice) Len() int

func (GroupSlice) Less

func (a GroupSlice) Less(i, j int) bool

func (GroupSlice) Swap

func (a GroupSlice) Swap(i, j int)

type Param

type Param struct {
	Key              string `json:"key" yaml:"key"`
	KeyPosition      string `json:"keyPosition" yaml:"key_position"`
	NotEmpty         bool   `json:"notEmpty" yaml:"not_empty"`
	ProxyKey         string `json:"proxyKey" yaml:"proxy_key"`
	ProxyKeyPosition string `json:"proxyKeyPosition" yaml:"proxy_key_position"`
}

type RateLimitInfo

type RateLimitInfo struct {
	LimitID   int    `json:"limitID" yaml:"limitI_id"`
	Allow     bool   `json:"allow" yaml:"allow"`
	Period    string `json:"period" yaml:"period"`
	Limit     int    `json:"limit" yaml:"limit"`
	Priority  int    `json:"priority" yaml:"priority"`
	StartTime int    `json:"startTime" yaml:"start_time"`
	EndTime   int    `json:"endTime" yaml:"end_time"`
}

func ParseRateLimitInfo

func ParseRateLimitInfo(path, strategyID string) ([]*RateLimitInfo, map[int]*RateLimitInfo, []map[string]interface{})

type Strategy

type Strategy struct {
	StrategyList []*StrategyInfo `json:"strategy" yaml:"strategy"`
}

type StrategyInfo

type StrategyInfo struct {
	StrategyName      string           `json:"strategyName" yaml:"strategy_name"`
	StrategyID        string           `json:"strategyID" yaml:"strategy_id"`
	Auth              string           `json:"auth,omitempty" yaml:"auth,omitempty"`
	BasicUserName     string           `json:"basicUserName,omitempty" yaml:"basic_user_name,omitempty"`
	BasicUserPassword string           `json:"basicUserPassword,omitempty" yaml:"basic_user_password,omitempty"`
	ApiKey            string           `json:"apiKey,omitempty" yaml:"api_key"`
	IPLimitType       string           `json:"ipLimitType,omitempty" yaml:"ip_limit_type,omitempty"`
	IPWhiteList       []string         `json:"ipWhiteList,omitempty" yaml:"ip_white_list,omitempty"`
	IPBlackList       []string         `json:"ipBlackList,omitempty" yaml:"ip_black_list,omitempty"`
	RateLimitList     []*RateLimitInfo `json:"rateLimitList,omitempty" yaml:"rate_limit_list,omitempty"`
	UpdateTime        string           `json:"updateTime,omitempty" yaml:"update_time,omitempty"`
	CreateTime        string           `json:"createTime,omitempty" yaml:"create_time,omitempty"`
}

func ParseStrategyInfo

func ParseStrategyInfo(path string) ([]*StrategyInfo, map[string]*StrategyInfo)

读入策略组信息

type StrategySlice

type StrategySlice []map[string]interface{}

func (StrategySlice) Len

func (s StrategySlice) Len() int

func (StrategySlice) Less

func (s StrategySlice) Less(i, j int) bool

func (StrategySlice) Swap

func (s StrategySlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL