GoLang-Beego使用

1.beego 注意事项

  beego的默认架构是mvc python的django默认是mtv

package main

import (
	"github.com/astaxie/beego"
)

type MainController struct {
	beego.Controller
}

func (this *MainController) Get(){
	this.Ctx.WriteString("hello mybeego")
}

func(this *MainController) Post(){
	user := this.GetString("username") //只能回去urlencode 为a=1&b=2格式
	//pwd := this.GetString("password")
	if user == ""{
		this.Ctx.WriteString("username not get,please check it")
	}else{
		this.Ctx.WriteString("111")
	}

}

func main(){
	beego.Router("/",&MainController{})
	beego.Run("127.0.0.1:9999")
}

  

猜你喜欢

转载自www.cnblogs.com/liujiliang/p/10027229.html