httpd: Move starting the http server into C.

This commit is contained in:
2025-02-02 12:27:06 -05:00
parent b111d06851
commit bb0ed67827
7 changed files with 213 additions and 183 deletions

View File

@ -212,14 +212,7 @@ static JSValue _file_read_file(JSContext* context, JSValueConst this_val, int ar
{
tf_task_t* task = JS_GetContextOpaque(context);
const char* file_name = JS_ToCString(context, argv[0]);
const char* actual = file_name;
if (tf_task_get_root_path(task))
{
size_t size = strlen(tf_task_get_root_path(task)) + strlen(file_name) + 2;
char* buffer = alloca(size);
snprintf(buffer, size, "%s/%s", tf_task_get_root_path(task), file_name);
actual = buffer;
}
const char* actual = tf_task_get_path_with_root(task, file_name);
promiseid_t promise = -1;
JSValue promise_value = tf_task_allocate_promise(task, &promise);
@ -241,6 +234,7 @@ static JSValue _file_read_file(JSContext* context, JSValueConst this_val, int ar
tf_free(req);
}
JS_FreeCString(context, file_name);
tf_free((char*)actual);
return promise_value;
}