beegoapix - beego api extension
簡介
beegoapix是一個beego API開發框架,用於快速開發API服務。
安裝
go get github.com/luffyke/beegoapix
功能
- 統一API請求處理和返回(v0.1)
- 統一日誌處理(v0.1)
- 異常控制(v0.1)
- API版本控制(v0.2)
- API許可權控制(v0.2)
- 組合介面
- 介面快取
- 自定義請求
示例
首先確保安裝beego和bee工具。
新建Api專案
bee api hello
編輯router.go,新增api路由
package routers
import (
"hello/controllers"
"github.com/luffyke/beegoapix"
)
func init() {
beegoapix.Router()
// add your business path mapping
beegoapix.RegController("app", controllers.AppController{})
}
實現業務controller
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"
}
}
Android 示例
相關文章
- beego 架構(API 版)Go架構API
- beego API自動化文件問題GoAPI
- [beego新手入門]基於web框架-beego的RESTful API的構建之旅GoWeb框架RESTAPI
- Lotus C API Extension Manager 應用舉例API
- 在Ubuntu上快速搭建基於Beego的RESTful APIUbuntuGoRESTAPI
- 面向 Extension 開發 ? Today Extension
- App ExtensionAPP
- Extension,CategoryGo
- Beego 再出發Go
- beego orm使用GoORM
- beego問題Go
- beego + jwt + vue + element-ui 構建的基於多家 API 的圖床GoJWTVueUIAPI圖床
- Hack With Chrome ExtensionChrome
- php mongodb extensionPHPMongoDB
- mysqlalchemy audit extensionMySql
- Tampermonkey & Extension
- Visual Studio Code Active File in StatusBar 擴充套件以及 Extension API 概述套件API
- Beego 框架巔峰之路Go框架
- beego tag詳解Go
- docker建立beego映象DockerGo
- beego訪問redisGoRedis
- beego & bee 1.9.0 releasedGo
- windows 安裝beegoWindowsGo
- App extension 總結APP
- chrome開發 extensionChrome
- IOS category 與 extensioniOSGo
- chrome extension/plugin pathChromePlugin
- App Extension Study 1APP
- 求救Beego大神們,Beego orm 怎麼限制Relation裡返回的Variable?GoORM
- Beego Models之二Go
- beego框架程式碼分析Go框架
- beego建立專案流程Go
- beego快取問題Go快取
- beego上傳檔案Go
- beego & bee 1.9.0 releasedGo
- Beego 自動化部署Go
- Swift學習之路-ExtensionSwift
- 談談Category和ExtensionGo