config.go 6.9 KB
Newer Older
Y
Your Name 已提交
1 2 3 4
package config

//GokuConfig goku根配置
type GokuConfig struct {
Y
Your Name 已提交
5 6 7 8
	Version      string `json:"version"`
	Cluster      string `json:"cluster"`
	Instance     string `json:"instance"`
	BindAddress  string `json:"bind"`
Y
Your Name 已提交
9 10
	AdminAddress string `json:"admin"`

Y
Your Name 已提交
11 12 13
	//Port                int                        `json:"port"`
	DiscoverConfig      map[string]*DiscoverConfig `json:"discover,omitempty"`
	Balance             map[string]*BalanceConfig  `json:"balance,omitempty"`
Y
Your Name 已提交
14
	Plugins             GatewayPluginConfig        `json:"plugins,omitempty"`
Y
Your Name 已提交
15 16 17 18
	APIS                []*APIContent              `json:"apis,omitempty"`
	Strategy            []*StrategyConfig          `json:"strategy,omitempty"`
	AnonymousStrategyID string                     `json:"anonymousStrategyID,omitempty"`
	AuthPlugin          map[string]string          `json:"authPlugin,omitempty"`
Y
Your Name 已提交
19 20 21 22 23 24 25 26 27
	GatewayBasicInfo    *Gateway                   `json:"gatewayBasicInfo"`
	//RouterRule          map[string]*RouterRule     `json:"routerRule"`
	Log            *LogConfig             `json:"log,omitempty"`
	AccessLog      *AccessLogConfig       `json:"access_log,omitempty"`
	Routers        []*Router              `json:"routers"`
	MonitorModules map[string]string      `json:"monitor_modules"`
	RedisConfig    map[string]interface{} `json:"redisConfig"`
	ExtendsConfig  map[string]interface{} `json:"extends_config"`
}
Y
Your Name 已提交
28

Y
Your Name 已提交
29 30 31 32 33 34
//Router 路由
type Router struct {
	Rules    string `json:"routerRules"`
	Target   string `json:"target"`
	Priority int    `json:"priority"`
}
Y
Your Name 已提交
35

Y
Your Name 已提交
36 37 38 39
//RouterRule 路由规则
type RouterRule struct {
	Host       string `json:"host"`
	StrategyID string `json:"strategyID"`
Y
Your Name 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
}

//AccessLogConfig access日志配置
type AccessLogConfig struct {
	Name   string   `json:"name"`
	Enable int      `json:"enable"`
	Dir    string   `json:"dir"`
	File   string   `json:"file"`
	Period string   `json:"period"`
	Expire int      `json:"expire"`
	Fields []string `json:"fields"`
}

//LogConfig log日志配置
type LogConfig struct {
	Name   string `json:"name"`
	Enable int    `json:"enable"`
	Dir    string `json:"dir"`
	File   string `json:"file"`
	Level  string `json:"level"`
	Period string `json:"period"`
	Expire int    `json:"expire"`
}

//GatewayPluginConfig 网关插件配置
type GatewayPluginConfig struct {
	BeforePlugins []*PluginConfig `json:"before"`
	GlobalPlugins []*PluginConfig `json:"global"`
}

//DiscoverConfig 服务发现配置
type DiscoverConfig struct {
	Name        string             `json:"name"`
	Driver      string             `json:"driver"`
	Config      string             `json:"config"`
	HealthCheck *HealthCheckConfig `json:"healthCheck"` // nil 表示不启用,非nil表示启用
}

//HealthCheckConfig 健康检查配置
type HealthCheckConfig struct {
	IsHealthCheck bool   `json:"is_health_check"`
	URL           string `json:"url"`
	Second        int    `json:"second"`
	TimeOutMill   int    `json:"timeoutMill"`
	StatusCode    string `json:"statusCode"`
}

//BalanceConfig 负载配置
type BalanceConfig struct {
	Name         string `json:"name"`
	DiscoverName string `json:"discover"`
	Config       string `json:"config"` // appName(for discovery) or  address (for static)
}

//PluginConfig 插件配置
type PluginConfig struct {
	Name      string `json:"name"`
	IsStop    bool   `json:"stop"`
	Config    string `json:"config"`
	UpdateTag string `json:"updateTag"`
Y
Your Name 已提交
100
	IsAuth    bool   `json:"isAuth"`
Y
Your Name 已提交
101 102 103 104
}

//APIContent api详情
type APIContent struct {
Y
Your Name 已提交
105 106 107 108
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Alias string `json:"alias"`

Y
Your Name 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
	OutPutEncoder  string           `json:"output"`
	RequestURL     string           `json:"requestUrl"`
	Methods        []string         `json:"methods"`
	TimeOutTotal   int              `json:"timeoutTotal"`
	AlertThreshold int              `json:"alert_threshold"`
	Steps          []*APIStepConfig `json:"steps"`

	StaticResponseStrategy string `json:"static_respone_strategy"`
	StaticResponse         string `json:"staticResponse"`
}

//APIStepConfig 链路配置
type APIStepConfig struct {
	Proto   string   `json:"proto"`
	Balance string   `json:"balance"`
	Method  string   `json:"method"` // follow | get | post | put ...
	Path    string   `json:"path"`
	Body    string   `json:"body"`
	Headers []string `json:"headers,omitempty"`
	Decode  string   `json:"decode"` // origin | json
	Encode  string   `json:"encode"` // origin | form | json

	Actions   []*ActionConfig `json:"actions"`
	BlackList []string        `json:"blackList"`
	WhiteList []string        `json:"whiteList"`

	Target  string `json:"target"`
	Group   string `json:"group"`
	Retry   int    `json:"retry"`
	TimeOut int    `json:"timeout"`
}

//APIStepUIConfig 链路UI配置
type APIStepUIConfig struct {
	Proto   string   `json:"proto"`
	Balance string   `json:"balance"`
	Method  string   `json:"method"` // follow | get | post | put ...
	Path    string   `json:"path"`
	Body    string   `json:"body"`
	Headers []string `json:"headers,omitempty"`
	Decode  string   `json:"decode"` // origin | json
	Encode  string   `json:"encode"` // origin | form | json

	BlackList []string `json:"blackList"`
	WhiteList []string `json:"whiteList"`

	Move    []MoveConfig   `json:"move"`
	Delete  []DeleteConfig `json:"delete"`
	Rename  []RenameConfig `json:"rename"`
	Target  string         `json:"target"`
	Group   string         `json:"group"`
	Retry   int            `json:"retry"`
	TimeOut int            `json:"timeout"`
}

//MoveConfig move配置
type MoveConfig struct {
	Origin string `json:"origin"`
	Target string `json:"target"`
}

//DeleteConfig delete配置
type DeleteConfig struct {
	Origin string `json:"origin"`
}

//RenameConfig rename配置
type RenameConfig struct {
	Origin string `json:"origin"`
	Target string `json:"target"`
}

//ActionConfig action配置
type ActionConfig struct {
	ActionType string `json:"type"`
	Original   string `json:"original"`
	Target     string `json:"target"`
}

//StrategyConfig 策略配置
type StrategyConfig struct {
	ID      string            `json:"id"`
	Name    string            `json:"name"`
	Enable  bool              `json:"enable"`
	APIS    []*APIOfStrategy  `json:"apis"`
	AUTH    map[string]string `json:"auth"`
	Plugins []*PluginConfig   `json:"plugins"`
}

Y
Your Name 已提交
198 199 200 201 202
//Gateway 网关配置
type Gateway struct {
	SkipCertificate int `json:"skipCertificate"`
}

Y
Your Name 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
//APIOfStrategy 策略接口配置
type APIOfStrategy struct {
	ID      int             `json:"id"`
	Balance string          `json:"balance"` // 单step有效
	Plugins []*PluginConfig `json:"plugins"`
}

//VersionConfig 版本配置
type VersionConfig struct {
	VersionID     int    `json:"versionID"`
	Name          string `json:"name"`
	Version       string `json:"version"`
	Remark        string `json:"remark"`
	CreateTime    string `json:"createTime"`
	PublishStatus int    `json:"publishStatus"`
	PublishTime   string `json:"publishTime"`
Y
Your Name 已提交
219
	Publisher     string `json:"publisher"`
Y
Your Name 已提交
220 221 222 223 224 225 226 227
}

//Project 项目
type Project struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	CreateTime string `json:"createTime"`
}