fetch body
This commit is contained in:
parent
98d0af014d
commit
91093ff64b
2 changed files with 30 additions and 4 deletions
|
|
@ -217,9 +217,15 @@ extern "C" {
|
|||
|
||||
export namespace Crafter::CppDOMBindings {
|
||||
__attribute__((import_module("env"), import_name("fetch"))) void Fetch(const char* url, std::int32_t urlLenght, std::int32_t handlerID);
|
||||
__attribute__((import_module("env"), import_name("fetchWithBody"))) void FetchWithBody(const char* url, std::int32_t urlLenght, const char* body, std::int32_t bodyLength, std::int32_t handlerID);
|
||||
void Fetch(const std::string_view url, std::function<void(std::string)> callback) {
|
||||
std::int32_t id = fetchHandlerMaxId++;
|
||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
||||
Fetch(url.data(), url.size(), id);
|
||||
}
|
||||
void Fetch(const std::string_view url, const std::string_view body, std::function<void(std::string)> callback) {
|
||||
std::int32_t id = fetchHandlerMaxId++;
|
||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
||||
FetchWithBody(url.data(), url.size(), body.data(), body.size(), id);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue