From 9dc62e14691380139c142847e7419bdaefa50cc4 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 25 Sep 2021 16:24:08 +0200 Subject: [PATCH] patterns: Added std::http::get --- .../builtin/source/content/pl_builtin_functions.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/builtin/source/content/pl_builtin_functions.cpp b/plugins/builtin/source/content/pl_builtin_functions.cpp index c5e0e062c..e16810c1b 100644 --- a/plugins/builtin/source/content/pl_builtin_functions.cpp +++ b/plugins/builtin/source/content/pl_builtin_functions.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -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 { + const auto url = Token::literalToString(params[0], false); + + hex::Net net; + return net.getString(url).get().body; + }); + } } }