Skip to content

Instantly share code, notes, and snippets.

@anidotnet
Created January 1, 2015 13:07
Show Gist options
  • Save anidotnet/24432c3305050516ef1d to your computer and use it in GitHub Desktop.
Save anidotnet/24432c3305050516ef1d to your computer and use it in GitHub Desktop.
package routers
import (
"github.com/astaxie/beego"
"apidemo/controllers"
)
func init() {
beego.Router("/v1/user/", &controllers.UserController{})
}
package controllers
import (
"github.com/astaxie/beego"
"apidemo/models"
)
func (c *UserController) URLMapping() {
c.Mapping("Get", c.Get)
}
type UserController struct {
beego.Controller
}
func (u *UserController) Get() {
users := models.GetAllUsers()
u.Data["json"] = users
u.ServeJson()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment