gpt4 book ai didi

go - Beego端点找不到模板文件…但是我没有使用模板

转载 作者:行者123 更新时间:2023-12-01 22:16:45 25 4
gpt4 key购买 nike

我在Beego应用程序上无法创建端点
因此,我只是将一些对象信息放在返回的JSON上:

// GetOne ...
// @Title GetOne
// @Description get Migration by id
// @Param id path string true "The key for staticblock"
// @Success 200 {object} models.Migration
// @Failure 403 :id is empty
// @router /:id [get]
func (c *MigrationController) GetOne() {
val, err := mg.Data["json"] = map[string]string{
"MigrationId": c.MigrationId
"Status": c.Status
"Created": c.Created
"Updated": c.Updated
}

if err != nil {
log.Debug("Fail - GetOne: %v", err)
} else {
mg.ServeJSON()
}
当我尝试调用端点时,我得到了
Handler crashed with error can't find templatefile in the path:views/migrationcontroller/getone.tpl
我不在整个代码中的任何地方使用这些模板...
我对这个框架不熟悉,有人可以帮助我吗?

最佳答案

您应该将ServeJSON()与当前 Controller 一起使用。

func (c *MigrationController) GetOne() {
defer c.ServeJSON()
...
}

关于go - Beego端点找不到模板文件…但是我没有使用模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59468547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com