router.go 9.4 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5
package console

import (
	"net/http"

黄孟柱 已提交
6
	config_log "github.com/eolinker/goku-api-gateway/console/controller/config-log"
E
eoLinker API Management 已提交
7

黄孟柱 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21
	"github.com/eolinker/goku-api-gateway/console/controller/account"
	"github.com/eolinker/goku-api-gateway/console/controller/alert"
	"github.com/eolinker/goku-api-gateway/console/controller/api"
	"github.com/eolinker/goku-api-gateway/console/controller/auth"
	"github.com/eolinker/goku-api-gateway/console/controller/balance"
	"github.com/eolinker/goku-api-gateway/console/controller/cluster"
	"github.com/eolinker/goku-api-gateway/console/controller/discovery"
	"github.com/eolinker/goku-api-gateway/console/controller/gateway"
	"github.com/eolinker/goku-api-gateway/console/controller/monitor"
	"github.com/eolinker/goku-api-gateway/console/controller/node"
	"github.com/eolinker/goku-api-gateway/console/controller/plugin"
	"github.com/eolinker/goku-api-gateway/console/controller/project"
	"github.com/eolinker/goku-api-gateway/console/controller/script"
	"github.com/eolinker/goku-api-gateway/console/controller/strategy"
E
eoLinker API Management 已提交
22 23
)

Y
Your Name 已提交
24
//Router 路由
E
eoLinker API Management 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
func Router() {

	// 游客
	http.HandleFunc("/guest/login", account.Login)

	// 用户
	http.HandleFunc("/user/logout", account.Logout)
	http.HandleFunc("/user/password/edit", account.EditPassword)
	http.HandleFunc("/user/getInfo", account.GetUserInfo)
	http.HandleFunc("/user/getUserType", account.GetUserType)
	http.HandleFunc("/user/checkIsAdmin", account.CheckUserIsAdmin)
	http.HandleFunc("/user/checkIsSuperAdmin", account.CheckUserIsSuperAdmin)
	http.HandleFunc("/user/checkPermission", account.CheckUserPermission)

	// 网关
	http.HandleFunc("/gateway/config/base/getInfo", gateway.GetGatewayConfig)
	http.HandleFunc("/gateway/config/base/edit", gateway.EditGatewayBaseConfig)
	http.HandleFunc("/gateway/config/alert/edit", gateway.EditGatewayAlarmConfig)
	http.HandleFunc("/gateway/config/alert/getInfo", alert.GetAlertConfig)

	// 监控

	http.HandleFunc("/monitor/gateway/getSummaryInfo", monitor.GetGatewayMonitorSummaryByPeriod)

	// 项目
	http.HandleFunc("/project/add", project.AddProject)
	http.HandleFunc("/project/edit", project.EditProject)
	http.HandleFunc("/project/delete", project.DeleteProject)
	http.HandleFunc("/project/getInfo", project.GetProjectInfo)
	http.HandleFunc("/project/getList", project.GetProjectList)
Y
Your Name 已提交
55
	http.HandleFunc("/project/strategy/getList", project.GetAPIListFromProjectNotInStrategy)
E
eoLinker API Management 已提交
56 57 58
	http.HandleFunc("/project/batchDelete", project.BatchDeleteProject)

	// 接口分组
Y
Your Name 已提交
59 60 61 62 63
	http.HandleFunc("/apis/group/add", api.AddAPIGroup)
	http.HandleFunc("/apis/group/edit", api.EditAPIGroup)
	http.HandleFunc("/apis/group/delete", api.DeleteAPIGroup)
	http.HandleFunc("/apis/group/getList", api.GetAPIGroupList)
	http.HandleFunc("/apis/group/update", api.UpdateAPIGroupScript)
E
eoLinker API Management 已提交
64 65

	// API
Y
Your Name 已提交
66 67 68 69 70 71 72 73
	http.HandleFunc("/apis/add", api.AddAPI)
	http.HandleFunc("/apis/edit", api.EditAPI)
	http.HandleFunc("/apis/copy", api.CopyAPI)
	http.HandleFunc("/apis/getInfo", api.GetAPIInfo)
	http.HandleFunc("/apis/getList", api.GetAPIList)
	http.HandleFunc("/apis/batchEditGroup", api.BatchEditAPIGroup)
	http.HandleFunc("/apis/batchDelete", api.BatchDeleteAPI)
	http.HandleFunc("/apis/batchEditBalance", api.BatchSetBalanceAPI)
E
eoLinker API Management 已提交
74

Y
Your Name 已提交
75
	http.HandleFunc("/apis/manager/getList", api.GetAPIManagerList)
E
eoLinker API Management 已提交
76 77

	// API绑定插件
Y
Your Name 已提交
78 79 80 81 82 83 84 85 86
	http.HandleFunc("/plugin/api/addPluginToAPI", api.AddPluginToAPI)
	http.HandleFunc("/plugin/api/edit", api.EditAPIPluginConfig)
	http.HandleFunc("/plugin/api/getInfo", api.GetAPIPluginConfig)
	http.HandleFunc("/plugin/api/getList", api.GetAPIPluginList)
	http.HandleFunc("/plugin/api/getListByStrategy", api.GetAllAPIPluginInStrategy)
	http.HandleFunc("/plugin/api/batchStart", api.BatchStartAPIPlugin)
	http.HandleFunc("/plugin/api/batchStop", api.BatchStopAPIPlugin)
	http.HandleFunc("/plugin/api/batchDelete", api.BatchDeleteAPIPlugin)
	http.HandleFunc("/plugin/api/notAssign/getList", api.GetAPIPluginListWithNotAssignAPIList)
E
eoLinker API Management 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 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

	// 策略绑定插件
	http.HandleFunc("/plugin/strategy/addPluginToStrategy", strategy.AddPluginToStrategy)
	http.HandleFunc("/plugin/strategy/edit", strategy.EditStrategyPluginConfig)
	http.HandleFunc("/plugin/strategy/getInfo", strategy.GetStrategyPluginConfig)
	http.HandleFunc("/plugin/strategy/getList", strategy.GetStrategyPluginList)
	http.HandleFunc("/plugin/strategy/checkPluginIsExist", strategy.CheckPluginIsExistInStrategy)
	http.HandleFunc("/plugin/strategy/getStatus", strategy.GetStrategyPluginStatus)
	http.HandleFunc("/plugin/strategy/batchStart", strategy.BatchStartStrategyPlugin)
	http.HandleFunc("/plugin/strategy/batchStop", strategy.BatchStopStrategyPlugin)
	http.HandleFunc("/plugin/strategy/batchDelete", strategy.BatchDeleteStrategyPlugin)

	// 告警
	http.HandleFunc("/alert/msg/getList", alert.GetAlertMsgList)
	http.HandleFunc("/alert/msg/clear", alert.ClearAlertMsg)
	http.HandleFunc("/alert/msg/delete", alert.DeleteAlertMsg)

	// 插件
	http.HandleFunc("/plugin/add", plugin.AddPlugin)
	http.HandleFunc("/plugin/edit", plugin.EditPlugin)
	http.HandleFunc("/plugin/delete", plugin.DeletePlugin)
	http.HandleFunc("/plugin/checkNameIsExist", plugin.CheckIndexIsExist)
	http.HandleFunc("/plugin/checkIndexIsExist", plugin.CheckNameIsExist)
	http.HandleFunc("/plugin/getList", plugin.GetPluginList)
	http.HandleFunc("/plugin/getInfo", plugin.GetPluginInfo)
	http.HandleFunc("/plugin/getConfig", plugin.GetPluginConfig)
	http.HandleFunc("/plugin/start", plugin.StartPlugin)
	http.HandleFunc("/plugin/stop", plugin.StopPlugin)
	http.HandleFunc("/plugin/getListByType", plugin.GetPluginListByPluginType)
	http.HandleFunc("/plugin/batchStop", plugin.BatchStopPlugin)
	http.HandleFunc("/plugin/batchStart", plugin.BatchStartPlugin)
	http.HandleFunc("/plugin/availiable/check", plugin.CheckPluginIsAvailable)

	// 策略组
	http.HandleFunc("/strategy/add", strategy.AddStrategy)
	http.HandleFunc("/strategy/edit", strategy.EditStrategy)
	http.HandleFunc("/strategy/copy", strategy.CopyStrategy)
	http.HandleFunc("/strategy/delete", strategy.DeleteStrategy)
	http.HandleFunc("/strategy/getList", strategy.GetStrategyList)
	http.HandleFunc("/strategy/getInfo", strategy.GetStrategyInfo)
	http.HandleFunc("/strategy/batchEditGroup", strategy.BatchEditStrategyGroup)
	http.HandleFunc("/strategy/batchDelete", strategy.BatchDeleteStrategy)
	http.HandleFunc("/strategy/batchStart", strategy.BatchStartStrategy)
	http.HandleFunc("/strategy/batchStop", strategy.BatchStopStrategy)
	// http.HandleFunc("/strategy/openStrategy/getInfo", strategy.GetOpenStrategy)

	// 策略组分组
	http.HandleFunc("/strategy/group/add", strategy.AddStrategyGroup)
	http.HandleFunc("/strategy/group/edit", strategy.EditStrategyGroup)
	http.HandleFunc("/strategy/group/delete", strategy.DeleteStrategyGroup)
	http.HandleFunc("/strategy/group/getList", strategy.GetStrategyGroupList)

	// 接口策略组
Y
Your Name 已提交
140 141 142 143 144 145
	http.HandleFunc("/strategy/api/add", strategy.AddAPIToStrategy)
	http.HandleFunc("/strategy/api/target", strategy.ResetAPITargetOfStrategy)
	http.HandleFunc("/strategy/api/batchEditTarget", strategy.BatchResetAPITargetOfStrategy)
	http.HandleFunc("/strategy/api/getList", strategy.GetAPIListFromStrategy)
	http.HandleFunc("/strategy/api/getNotInList", strategy.GetAPIListNotInStrategy)
	http.HandleFunc("/strategy/api/batchDelete", strategy.BatchDeleteAPIInStrategy)
E
eoLinker API Management 已提交
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
	http.HandleFunc("/strategy/api/plugin/getList", api.GetAPIPluginInStrategyByAPIID)

	http.HandleFunc("/strategy/balance/getList", strategy.GetBalanceListInStrategy)

	// 节点
	http.HandleFunc("/node/add", node.AddNode)
	http.HandleFunc("/node/edit", node.EditNode)
	http.HandleFunc("/node/delete", node.DeleteNode)
	http.HandleFunc("/node/getInfo", node.GetNodeInfo)
	http.HandleFunc("/node/getList", node.GetNodeList)
	http.HandleFunc("/node/checkIsExistRemoteAddr", node.CheckIsExistRemoteAddr)

	http.HandleFunc("/node/batchEditGroup", node.BatchEditNodeGroup)
	http.HandleFunc("/node/batchDelete", node.BatchDeleteNode)

	// 节点分组
	http.HandleFunc("/node/group/add", node.AddNodeGroup)
	http.HandleFunc("/node/group/edit", node.EditNodeGroup)
	http.HandleFunc("/node/group/delete", node.DeleteNodeGroup)
	http.HandleFunc("/node/group/getInfo", node.GetNodeGroupInfo)
	http.HandleFunc("/node/group/getList", node.GetNodeGroupList)

	// 负载均衡
	http.HandleFunc("/balance/add", balance.AddBalance)
	http.HandleFunc("/balance/edit", balance.SaveBalance)
	http.HandleFunc("/balance/delete", balance.DeleteBalance)
	http.HandleFunc("/balance/getInfo", balance.GetBalanceInfo)
	http.HandleFunc("/balance/getList", balance.GetBalanceList)
	http.HandleFunc("/balance/batchDelete", balance.BatchDeleteBalance)
	http.HandleFunc("/balance/simple", balance.GetSimpleList)

	// 服务发现
	http.Handle("/balance/service/", discovery.Handle("/balance/service"))

	// 鉴权
	http.HandleFunc("/auth/getStatus", auth.GetAuthStatus)
	http.HandleFunc("/auth/getInfo", auth.GetAuthInfo)
	http.HandleFunc("/auth/editInfo", auth.EditAuthInfo)

	// 导入
Y
Your Name 已提交
186 187
	http.HandleFunc("/import/ams/api", api.ImportAPIFromAms)
	http.HandleFunc("/import/ams/group", api.ImportAPIGroupFromAms)
E
eoLinker API Management 已提交
188 189 190 191 192 193 194 195
	http.HandleFunc("/import/ams/project", api.ImportProjectFromAms)

	// 	集群

	http.HandleFunc("/cluster/list", cluster.GetClusterInfoList)
	http.HandleFunc("/cluster/simpleList", cluster.GetClusterList)

	// 脚本
Y
Your Name 已提交
196
	http.HandleFunc("/scrpit/refreshAPIInfo", script.RefreshAPIInfo)
E
eoLinker API Management 已提交
197 198 199 200 201 202
	http.HandleFunc("/scrpit/refreshGatewayAlertConfig", script.RefreshGatewayAlertConfig)
	// 配置
	http.Handle("/config/log/", config_log.Handle("/config/log/"))
	http.HandleFunc("/", http.StripPrefix("/", http.FileServer(http.Dir("./static"))).ServeHTTP)

}