mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:15:10 +00:00
[ADD/WIP] Start making a simple SAX parser, ASwerk
This commit is contained in:
parent
0fa95c2d14
commit
79217d3608
14 changed files with 1066 additions and 26 deletions
37
src/Routes/Ping.c
Normal file
37
src/Routes/Ping.c
Normal 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;
|
||||
}
|
||||
|
|
@ -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\">");
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue