add get version restful api

This commit is contained in:
xiongguangjie 2022-08-12 18:09:44 +08:00
parent 6382fcb3be
commit a1000da71f
2 changed files with 43 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"info": { "info": {
"_postman_id": "fe6cdfbd-531d-45e6-87e5-d460ce9e6328", "_postman_id": "4626d766-16b5-4255-89ba-f7614de2398c",
"name": "ZLMediaKit", "name": "ZLMediaKit",
"description": "媒体服务器", "description": "媒体服务器",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
@ -1087,7 +1087,7 @@
}, },
{ {
"key": "speed", "key": "speed",
"value": 2.0, "value": "2.0",
"description": "要设置的录像倍速" "description": "要设置的录像倍速"
} }
] ]
@ -1690,6 +1690,31 @@
} }
}, },
"response": [] "response": []
},
{
"name": "获取版本信息(version)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{ZLMediaKit_URL}}/index/api/version?secret={{ZLMediaKit_secret}}",
"host": [
"{{ZLMediaKit_URL}}"
],
"path": [
"index",
"api",
"version"
],
"query": [
{
"key": "secret",
"value": "{{ZLMediaKit_secret}}"
}
]
}
},
"response": []
} }
], ],
"event": [ "event": [

View File

@ -48,6 +48,10 @@
#include <tchar.h> #include <tchar.h>
#endif // _WIN32 #endif // _WIN32
#if defined(ENABLE_VERSION)
#include "version.h"
#endif
using namespace std; using namespace std;
using namespace Json; using namespace Json;
using namespace toolkit; using namespace toolkit;
@ -1542,6 +1546,18 @@ void installWebApi() {
}); });
#endif #endif
#if defined(ENABLE_VERSION)
api_regist("/index/api/version",[](API_ARGS_MAP_ASYNC){
CHECK_SECRET();
Value ver;
ver["buildTime"] = BUILD_TIME;
ver["branchName"] = BRANCH_NAME;
ver["commitHash"] = COMMIT_HASH;
val["data"] = ver;
invoker(200, headerOut, val.toStyledString());
});
#endif
////////////以下是注册的Hook API//////////// ////////////以下是注册的Hook API////////////
api_regist("/index/hook/on_publish",[](API_ARGS_JSON){ api_regist("/index/hook/on_publish",[](API_ARGS_JSON){
//开始推流事件 //开始推流事件