mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 14:12:25 +00:00
add MP.HttpsGET, MP.HttpsPOST
This commit is contained in:
+12
-2
@@ -1,11 +1,13 @@
|
|||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "CustomAssert.h"
|
#include "CustomAssert.h"
|
||||||
|
#include "Http.h"
|
||||||
#include "LuaAPI.h"
|
#include "LuaAPI.h"
|
||||||
#include "TLuaPlugin.h"
|
#include "TLuaPlugin.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
static std::mt19937_64 MTGen64;
|
static std::mt19937_64 MTGen64;
|
||||||
|
|
||||||
@@ -307,8 +309,16 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, std::atomi
|
|||||||
});
|
});
|
||||||
Table.set_function("Sleep", &LuaAPI::MP::Sleep);
|
Table.set_function("Sleep", &LuaAPI::MP::Sleep);
|
||||||
Table.set_function("Set", &LuaAPI::MP::Set);
|
Table.set_function("Set", &LuaAPI::MP::Set);
|
||||||
//Table.set_function("HttpsGET", &LuaAPI::MP::HttpsGET);
|
Table.set_function("HttpsGET", [&](const std::string& Host, int Port, const std::string& Target) -> std::tuple<int, std::string> {
|
||||||
//Table.set_function("HttpsPOST", &LuaAPI::MP::HttpsPOST);
|
unsigned Status;
|
||||||
|
auto Body = Http::GET(Host, Port, Target, &Status);
|
||||||
|
return { Status, Body };
|
||||||
|
});
|
||||||
|
Table.set_function("HttpsPOST", [&](const std::string& Host, int Port, const std::string& Target, const std::string& Body, const std::string& ContentType) -> std::tuple<int, std::string> {
|
||||||
|
unsigned Status;
|
||||||
|
auto ResponseBody = Http::POST(Host, Port, Target, {}, Body, ContentType, &Status);
|
||||||
|
return { Status, ResponseBody };
|
||||||
|
});
|
||||||
Table.create_named("Settings",
|
Table.create_named("Settings",
|
||||||
"Debug", 0,
|
"Debug", 0,
|
||||||
"Private", 1,
|
"Private", 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user