Skip to content

Instantly share code, notes, and snippets.

@anidotnet
Created January 1, 2015 11:04
Show Gist options
  • Save anidotnet/a575d176ceaadbe9e112 to your computer and use it in GitHub Desktop.
Save anidotnet/a575d176ceaadbe9e112 to your computer and use it in GitHub Desktop.
package routers
import (
"github.com/astaxie/beego"
"apidemo/controllers"
)
func init() {
beego.Include(&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
}
// @router /v1/user/ [get]
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