port to crafter.build v2
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d4f540bcc
commit
4e097d2b2d
8 changed files with 156 additions and 193 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Crafter® Build
|
||||
Copyright (C) 2025 Catcrafts®
|
||||
Copyright (C) 2026 Catcrafts®
|
||||
Catcrafts.net
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
|
@ -22,23 +22,22 @@ import Crafter.Network;
|
|||
import std;
|
||||
using namespace Crafter;
|
||||
|
||||
extern "C" {
|
||||
std::string* RunTest() {
|
||||
bool success = false;
|
||||
ListenerAsyncHTTP listener(8080, {{"/", [&](const HTTPRequest& request) {
|
||||
success = true;
|
||||
return CreateResponseHTTP("200 OK", "Hello World!");
|
||||
}}});
|
||||
try {
|
||||
system("curl http://localhost:8080 > /dev/null 2>&1");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
if (success) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return new std::string("Did not receive");
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
return new std::string(e.what());
|
||||
int main() {
|
||||
bool success = false;
|
||||
ListenerAsyncHTTP listener(8081, {{"/", [&](const HTTPRequest& request) {
|
||||
success = true;
|
||||
return CreateResponseHTTP("200 OK", "Hello World!");
|
||||
}}});
|
||||
try {
|
||||
system("curl http://localhost:8081 > /dev/null 2>&1");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
if (success) {
|
||||
return 0;
|
||||
}
|
||||
std::println("Did not receive");
|
||||
return 1;
|
||||
} catch (std::exception& e) {
|
||||
std::println("{}", e.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue