洞察企业如何通过模块化APP集成工具高效管理多平台小程序
924
2022-10-19
beegoapix 是 beego api 扩展框架
中文文档
beegoapix
beegoapix is beego api extension framework, to develop more faster api service.
Install
go get github.com/luffyke/beegoapix
Function
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 controllerCache(etag)
Demo
Setup environment
go get github.com/astaxie/beegogo get github.com/luffyke/beegoapixgo get github.com/beego/bee
New api project
bee api hello
Edit router.go
package routersimport ( "hello/controllers" "github.com/luffyke/beegoapix")func init() { beegoapix.Router() // add your business path mapping beegoapix.RegController("app", controllers.AppController{})}
Business controller
package controllersimport ( "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}
Run the server
bee run
Post the request
http://localhost:8080/v1/app/check-version
Request
{ "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" }}
Response
{ "state": { "code": 0, "msg": "" }, "data": { "versionName": "version name 1.0" }}
Deploy
setup go environmentinstall beego and beegoapix
go get github.com/astaxie/beegogo get github.com/luffyke/beegoapix
download and run beego deploy shell
Android demo
please reference to project beegoapix-android-demo
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~