diff options
| author | Stefan Boberg <[email protected]> | 2021-11-18 21:14:01 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-11-18 21:14:01 +0100 |
| commit | 4339b4f6772ad543002044c002f807c7dcdf4879 (patch) | |
| tree | 564d44209d6331cb2cb7d5ac9ef2fee1de181d2f /zenhttp/include | |
| parent | merged from main (diff) | |
| download | zen-4339b4f6772ad543002044c002f807c7dcdf4879.tar.xz zen-4339b4f6772ad543002044c002f807c7dcdf4879.zip | |
rpc: tactical checkin
Diffstat (limited to 'zenhttp/include')
| -rw-r--r-- | zenhttp/include/zenhttp/httpserver.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/zenhttp/include/zenhttp/httpserver.h b/zenhttp/include/zenhttp/httpserver.h index 93ba452c7..19b4c63d6 100644 --- a/zenhttp/include/zenhttp/httpserver.h +++ b/zenhttp/include/zenhttp/httpserver.h @@ -4,6 +4,7 @@ #include "zenhttp.h" +#include <zencore/compactbinary.h> #include <zencore/enumflags.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> @@ -15,6 +16,7 @@ #include <functional> #include <gsl/gsl-lite.hpp> #include <list> +#include <map> #include <regex> #include <span> #include <unordered_map> @@ -269,6 +271,38 @@ private: std::unordered_map<std::string, std::string> m_PatternMap; }; +/** HTTP RPC request helper + */ + +class RpcResult +{ + RpcResult(CbObject Result) : m_Result(std::move(Result)) {} + +private: + CbObject m_Result; +}; + +class HttpRpcHandler +{ +public: + HttpRpcHandler(); + ~HttpRpcHandler(); + + HttpRpcHandler(const HttpRpcHandler&) = delete; + HttpRpcHandler operator=(const HttpRpcHandler&) = delete; + + void AddRpc(std::string_view RpcId, std::function<void(CbObject& RpcArgs)> HandlerFunction); + +private: + struct RpcFunction + { + std::function<void(CbObject& RpcArgs)> Function; + std::string Identifier; + }; + + std::map<std::string, RpcFunction> m_Functions; +}; + void http_forcelink(); // internal } // namespace zen |