get.go 890 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5
package balance

import (
	"net/http"

黄孟柱 已提交
6 7
	"github.com/eolinker/goku-api-gateway/console/controller"
	"github.com/eolinker/goku-api-gateway/console/module/balance"
E
eoLinker API Management 已提交
8 9
)

Y
Your Name 已提交
10
//GetBalanceInfo 获取负载信息
E
eoLinker API Management 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
func GetBalanceInfo(httpResponse http.ResponseWriter, httpRequest *http.Request) {
	_, e := controller.CheckLogin(httpResponse, httpRequest, controller.OperationLoadBalance, controller.OperationREAD)
	if e != nil {
		return
	}
	if err := httpRequest.ParseForm(); err != nil {
		controller.WriteError(httpResponse, "501", "balance", "[ERROR]参数解析错误t!", err)
		return
	}
	balanceName := httpRequest.FormValue("balanceName")
	info, err := balance.Get(balanceName)

	if err != nil {
		controller.WriteError(httpResponse, "260000", "balance", "[ERROR]The balance does not exist!", err)
		return
	}

	controller.WriteResultInfo(httpResponse, "balance", "balanceInfo", info)

	return
}