beegoapix is beego api extension framework, to develop more faster api service.
go get github.com/luffyke/beegoapix
- Http API handling, accept all client http request, reflect and call sub-controller to handle request(v0.1)
- Logging, log request and response(v0.1)
- Error handling(v0.1)
- API version control(v0.2)
- API authority control(v0.2)
- Combine controller
- Cache(etag)
go get github.com/astaxie/beego
go get github.com/luffyke/beegoapix
go get github.com/beego/bee
bee api hello
package routers
import (
"hello/controllers"
"github.com/luffyke/beegoapix"
)
func init() {
beegoapix.Router()
// add your business path mapping
beegoapix.RegController("app", controllers.AppController{})
}
package controllers
import (
"github.com/luffyke/beegoapix/api"
"github.com/astaxie/beego/logs"
)
type AppController struct {
}
func (this *AppController) CheckVersion(request api.ApiRequest) (response api.ApiResponse) {
logs.Debug(request.Id)
logs.Debug(request.Data["versionCode"])
response.Data = make(map[string]interface{})
response.Data["versionName"] = "version name 1.0"
return response
}
bee run
http://localhost:8080/v1/app/check-version
{
"id":"12345678",
"sign":"abc",
"client":{
"caller":"app",
"os":"android",
"ver":"1.0",
"platform":"android",
"ch":"offical",
"ex":{
"imei":"1a2b3c"
}
},
"page":{
"page":1,
"size":10
},
"user":{
"uid":"123",
"sid":"abc"
},
"data":{
"versionCode":"v1.0.0"
}
}
{
"state": {
"code": 0,
"msg": ""
},
"data": {
"versionName": "version name 1.0"
}
}
- setup go environment
- install beego and beegoapix
go get github.com/astaxie/beego
go get github.com/luffyke/beegoapix
- download and run beego deploy shell
please reference to project beegoapix-android-demo