Esempio n. 1
0
// @Title GetHost
// @Description get host by id
// @Param	id		path 	int	true		"The key for staticblock"
// @Success {code:200, data:object} models.Host
// @Failure {code:int, msg:string}
// @router /:id [get]
func (c *HostController) GetHost() {
	id, err := c.GetInt(":id")
	if err != nil {
		c.SendMsg(403, err.Error())
	} else {
		host, err := models.GetHost(id)
		if err != nil {
			c.SendMsg(403, err.Error())
		} else {
			c.SendObj(200, host)
		}
	}
}
Esempio n. 2
0
func (c *MainController) EditHost() {
	var host *models.Host

	id, err := c.GetInt(":id")
	if err != nil {
		goto out
	}

	host, err = models.GetHost(id)
	if err != nil {
		goto out
	}

	c.PrepareEnv()
	c.Data["Host"] = host
	c.Data["H1"] = "edit host"
	c.Data["Method"] = "put"
	c.TplName = "host/edit.tpl"
	return
out:
	c.SendMsg(400, err.Error())
}