Exemplo n.º 1
0
func appGet(c echo.Context) error {

	ty := c.QueryParam("type")
	var returnValue proto.Message
	var err error
	var Region = c.QueryParam("region")

	if ty == "value" { // 获取单个应用信息
		args := new(types.GetParams)
		app := new(types.App)
		returnValue = app
		args.Region = Region
		args.Id = c.QueryParam("id")
		err = appHandler.Get(args, app)
	} else { // 获取应用列表
		args := new(types.ListParams)
		applist := new(types.AppList)
		returnValue = applist
		args.Region = Region
		args.Offset = 0  // 列表偏移量
		args.Length = 10 // 列表长度
		err = appHandler.List(args, applist)
	}

	// 获取数据失败
	if err != nil {
		return SendData(c, http.StatusNotFound, returnValue)
	}

	return SendData(c, http.StatusOK, returnValue)
}
Exemplo n.º 2
0
func appTempGet(c echo.Context) error {

	args := new(types.GetParams)
	app := new(types.App)

	args.Region = c.QueryParam("region")

	if args.Region == "" {
		args.Region = types.DefaultRegion
	}

	args.Id = c.QueryParam("id")
	err := appTempHandler.Get(args, app)
	// 获取数据失败
	if err != nil {
		return c.String(http.StatusNotFound, "")
	}
	return SendData(c, http.StatusOK, app)
}
Exemplo n.º 3
0
func TestAppTempGet(t *testing.T) {
	Init()
	arg := new(types.GetParams)
	arg.Id = "redis"
	arg.Region = ""
	app := new(types.App)

	appTempHandler := AppTempHandler{}

	err := appTempHandler.Get(arg, app)
	if err != nil {
		t.Error("AppHandler get err:", err)
	}
}
Exemplo n.º 4
0
func podGet(c echo.Context) error {

	var arg = new(types.GetParams)
	arg.Region = c.QueryParam("region")
	arg.ParentId = c.QueryParam("appid")
	arg.Id = c.QueryParam("id")
	var pod = new(types.Pod)

	err := podHandler.Get(arg, pod)
	if err != nil {
		return SendData(c, http.StatusNotFound, pod)
	}
	return SendData(c, http.StatusOK, pod)
}