Reputation: 2140
I'm using Beego and I don't think the annotation routing works as documented.
My router.go looks like this:
package routers
import (
beego "github.com/beego/beego/v2/server/web"
"project/controllers"
)
func init() {
beego.Include(&controllers.InventoryController{})
}
I have confirmed that the router is being initialized (I import it in main.go
).
And the controller looks like this:
package controllers
import (
"encoding/json"
"fmt"
beego "github.com/beego/beego/v2/server/web"
)
type InventoryController struct {
beego.Controller
}
func (c *InventoryController) URLMapping() {
c.Mapping("Index", c.Index)
}
// @router /index [get]
func (c *InventoryController) Index() {
var accountId string
accountId = fmt.Sprintf("%s", c.Ctx.Input.GetData("account_id"))
// do stuff
c.Data["json"] = map[string]interface{}{"accountId": accountId}
c.ServeJSON()
}
When I visit GET /index
I receive a 404
error.
Is there some sort of generation step that I need to take?
Upvotes: 1
Views: 404