Introduce HTTP API for plugins (#5383)

This commit is contained in:
Mm2PL
2024-06-22 12:04:30 +02:00
committed by GitHub
parent 7dc80bc599
commit c980162656
19 changed files with 1166 additions and 11 deletions
@@ -3,10 +3,13 @@
# include "Application.hpp"
# include "common/Args.hpp"
# include "common/network/NetworkCommon.hpp"
# include "common/QLogging.hpp"
# include "controllers/commands/CommandContext.hpp"
# include "controllers/commands/CommandController.hpp"
# include "controllers/plugins/api/ChannelRef.hpp"
# include "controllers/plugins/api/HTTPRequest.hpp"
# include "controllers/plugins/api/HTTPResponse.hpp"
# include "controllers/plugins/api/IOWrapper.hpp"
# include "controllers/plugins/LuaAPI.hpp"
# include "controllers/plugins/LuaUtilities.hpp"
@@ -174,10 +177,19 @@ void PluginController::openLibrariesFor(lua_State *L, const PluginMeta &meta,
lua::pushEnumTable<Channel::Type>(L);
lua_setfield(L, c2libIdx, "ChannelType");
lua::pushEnumTable<NetworkRequestType>(L);
lua_setfield(L, c2libIdx, "HTTPMethod");
// Initialize metatables for objects
lua::api::ChannelRef::createMetatable(L);
lua_setfield(L, c2libIdx, "Channel");
lua::api::HTTPRequest::createMetatable(L);
lua_setfield(L, c2libIdx, "HTTPRequest");
lua::api::HTTPResponse::createMetatable(L);
lua_setfield(L, c2libIdx, "HTTPResponse");
lua_setfield(L, gtable, "c2");
// ban functions