gateway.go 881 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3
package gateway

import (
Y
Your Name 已提交
4
	"encoding/json"
E
eoLinker API Management 已提交
5 6
	"net/http"

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

Y
Your Name 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//GetGatewayBasicInfo 获取网关基本信息
func GetGatewayBasicInfo(httpResponse http.ResponseWriter, httpRequest *http.Request) {
	_, e := controller.CheckLogin(httpResponse, httpRequest, controller.OperationNone, controller.OperationREAD)
	if e != nil {
		return
	}

	flag, result, err := gateway.GetGatewayMonitorSummaryByPeriod()
	if !flag {
		controller.WriteError(httpResponse,
			"340000",
			"monitor",
			"[ERROR]The gateway basic information does not exist!",
			err)
		return

	}
	monitorInfo := map[string]interface{}{
		"statusCode": "000000",
		"type":       "monitor",
		"baseInfo":   result.BaseInfo,
	}
	info, _ := json.Marshal(monitorInfo)

	httpResponse.Write(info)
	return

}