mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
调试修改HTTP接口
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
#include "httplib.h"
|
||||
#include "httplib.h"
|
||||
#include "common/JsonN.h"
|
||||
#include "errcode.h"
|
||||
#include <functional>
|
||||
|
||||
class HttpEntity;
|
||||
using HandlerFunc = Errcode(HttpEntity::*)(const httplib::Request& req, httplib::Response& resp, NJsonNode& jnode);
|
||||
|
||||
struct HandlerOptions
|
||||
{
|
||||
HandlerFunc func;
|
||||
std::vector<std::string> requiredKeys;
|
||||
std::vector<std::string> keys;
|
||||
|
||||
HandlerOptions(HandlerFunc func, const std::vector<std::string>& requiredKeys)
|
||||
: func(func), requiredKeys(requiredKeys)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class HttpEntity
|
||||
{
|
||||
@@ -8,6 +24,7 @@ public:
|
||||
httplib::Server httpsvr;
|
||||
HttpEntity();
|
||||
void listen(std::string addr, int port);
|
||||
void runHandler(std::string name, const HandlerOptions& handler, const httplib::Request& req, httplib::Response& resp);
|
||||
void registGet(std::string name, void (HttpEntity::* func)(const httplib::Request& req, httplib::Response& resp));
|
||||
|
||||
//void onGet(const httplib::Request& req, httplib::Response& resp);
|
||||
|
||||
Reference in New Issue
Block a user