1
0
mirror of synced 2024-11-28 17:40:51 +01:00

patterns: Added std::http::get

This commit is contained in:
WerWolv 2021-09-25 16:24:08 +02:00
parent 55c0cb66e3
commit 9dc62e1469

View File

@ -2,6 +2,7 @@
#include <hex/helpers/shared_data.hpp> #include <hex/helpers/shared_data.hpp>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>
#include <hex/helpers/net.hpp>
#include <hex/pattern_language/token.hpp> #include <hex/pattern_language/token.hpp>
#include <hex/pattern_language/log_console.hpp> #include <hex/pattern_language/log_console.hpp>
@ -213,6 +214,17 @@ namespace hex::plugin::builtin {
}); });
} }
ContentRegistry::PatternLanguageFunctions::Namespace nsStdHttp = { "std", "http" };
{
/* get(url) */
ContentRegistry::PatternLanguageFunctions::add(nsStdHttp, "get", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
const auto url = Token::literalToString(params[0], false);
hex::Net net;
return net.getString(url).get().body;
});
}
} }
} }