12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /*
- * @Description: ApiServer api服务器
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2022-04-01 15:44:09
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-04-15 11:19:25
- */
- #ifndef __APISERVER_HPP_
- #define __APISERVER_HPP_
- #include <iostream>
- #include "HttpServer.h"
- #include "hssl.h"
- #include "ins_base.hpp"
- using namespace std;
- namespace ins{
- class ApiServer:public Module
- {
- private:
- ApiServer(int port) : Module("ApiServer"), port_(port){
- Init();
- }
- /**
- * @description: 注册API
- * @param {*}
- * @return {*}
- */
- int8_t RegisterApi();
- public:
- using Ptr = std::shared_ptr<ApiServer>;
-
- virtual ~ApiServer(){this->Destroy();}
-
- /**
- * @description: 初始化
- * @param {*}
- * @return {*}
- */
- int8_t Init() override;
- /**
- * @description: 创建实例
- * @param {*}
- * @return {*}
- */
- static std::shared_ptr<ApiServer> CreateNew(int port);
- /**
- * @description: 获取实例
- * @param {*}
- * @return {*}
- */
- static std::shared_ptr<ApiServer> getPtr();
- /**
- * @description: 释放资源
- * @param {*}
- * @return {*}
- */
- void Destroy() override;
- /**
- * @description: 运行
- * @param {*}
- * @return {*}
- */
- int8_t Run();
- /**
- * @description: 是否正常
- * @param {*}
- * @return {*}
- */
- bool isNormally() override{
- return true;
- }
-
- protected:
- int port_;
- http_server_t server_;
- std::shared_ptr<HttpService> m_HttpService = nullptr;
- };
- };
- // 任务管理器
- #endif
|