beego路由匹配(记录)

来源:互联网 发布:java工程师简历项目 编辑:程序博客网 时间:2024/06/18 17:53

beego

路由匹配

beego.Router(“/api/?:id”,&controllers.RController{})—————————————————————————————————————————————————————http://localhost:8080/user/dds?id=2dd1:=c.Ctx.Input.Param(":id")//获取ddsdd2:=c.Ctx.Input.Query("id")//获取2

数据绑定

支持从用户请求中直接数据 bind 到指定的对象,例如请求地址如下

?id=123&isok=true&ft=1.2&ol[0]=1&ol[1]=2&ul[]=str&ul[]=array&user.Name=astaxie
var id intthis.Ctx.Input.Bind(&id, "id")  //id ==123var isok boolthis.Ctx.Input.Bind(&isok, "isok")  //isok ==truevar ft float64this.Ctx.Input.Bind(&ft, "ft")  //ft ==1.2ol := make([]int, 0, 2)this.Ctx.Input.Bind(&ol, "ol")  //ol ==[1 2]ul := make([]string, 0, 2)this.Ctx.Input.Bind(&ul, "ul")  //ul ==[str array]user struct{Name}this.Ctx.Input.Bind(&user, "user")  //user =={Name:"astaxie"}