[ADD/WIP] Start making a simple SAX parser, ASwerk

This commit is contained in:
LDA 2024-06-15 12:29:34 +02:00
commit 79217d3608
14 changed files with 1066 additions and 26 deletions

37
src/Routes/Ping.c Normal file
View file

@ -0,0 +1,37 @@
#include <Routes.h>
#include <Cytoplasm/Log.h>
#include <Matrix.h>
#include <AS.h>
RouteHead(RoutePing, arr, argp)
{
ParseeHttpArg *args = argp;
HashMap *request = NULL;
HashMap *response = NULL;
response = ASVerifyRequest(args);
if (response)
{
goto end;
}
if (HttpRequestMethodGet(args->ctx) != HTTP_POST)
{
HttpResponseStatus(args->ctx, HTTP_METHOD_NOT_ALLOWED);
response = MatrixCreateError(
"M_UNRECOGNIZED",
"Path /ping only accepts POST as a valid method."
);
goto end;
}
Log(LOG_INFO, "Pong!");
RequestJSON();
/* TODO: Load ping info */
response = HashMapCreate();
end:
JsonFree(request);
return response;
}

View file

@ -1,9 +1,13 @@
#include <Routes.h>
#include <AS.h>
RouteHead(RouteRoot, arr, argp)
{
ParseeHttpArg *args = argp;
ASPing(args->data->config);
HttpResponseHeader(args->ctx, "Content-Type", "text/html");
HttpSendHeaders(args->ctx);
StreamPrintf(args->stream, "<html lang=\"en\">");

View file

@ -38,11 +38,11 @@ RouteHead(RouteTxns, arr, argp)
for (i = 0; i < ArraySize(events); i++)
{
HashMap *event = JsonValueAsObject(ArrayGet(events, i));
Log(LOG_INFO, "Event by '%s', with type '%s'",
JsonValueAsString(HashMapGet(event, "sender")),
JsonValueAsString(HashMapGet(event, "type"))
);
ParseeEventHandler(args->data->config, event);
}
/* TODO: Store TXN ID somewhere so that we can commit
* "Epic Matrix Idempotency" */
Log(LOG_INFO, "OK!");
response = HashMapCreate();