GO Rest API

URL	HTTP    Verb	Functionality
/object	POST	Creating Objects
/object/objectId	GET	Retrieving Objects
/object/objectId	PUT	Updating Objects
/object	GET	Queries
/object/objectId	DELETE	Deleting Objects


type ObejctController struct {
    beego.Controller
}

func (this *ObejctController) Post(){

}

func (this *ObejctController) Get(){

}

func (this *ObejctController) Put(){

}

func (this *ObejctController) Delete(){

}


测试

添加一个对象:

curl -X POST -d '{"Score":1337,"PlayerName":"Sean Plott"}' http://127.0.0.1:8080/object

返回一个相应的objectID:astaxie1373349756660423900

查询一个对象

curl -X GET http://127.0.0.1:8080/object/astaxie1373349756660423900

查询全部的对象

curl -X GET http://127.0.0.1:8080/object

更新一个对象

curl -X PUT -d '{"Score":10000}'http://127.0.0.1:8080/object/astaxie1373349756660423900

删除一个对象

curl -X DELETE http://127.0.0.1:8080/object/astaxie1373349756660423900

猜你喜欢

转载自37235798.iteye.com/blog/2302305