mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 15:05:11 +00:00
48 lines
1.1 KiB
C
48 lines
1.1 KiB
C
#include <Routes.h>
|
|
|
|
#include <Cytoplasm/Log.h>
|
|
|
|
#include <Matrix.h>
|
|
#include <AS.h>
|
|
|
|
RouteHead(RouteTxns, arr, argp)
|
|
{
|
|
ParseeHttpArg *args = argp;
|
|
HashMap *request = NULL;
|
|
HashMap *response = NULL;
|
|
Array *events;
|
|
size_t i;
|
|
|
|
response = ASVerifyRequest(args);
|
|
if (response)
|
|
{
|
|
goto end;
|
|
}
|
|
if (HttpRequestMethodGet(args->ctx) != HTTP_PUT)
|
|
{
|
|
HttpResponseStatus(args->ctx, HTTP_METHOD_NOT_ALLOWED);
|
|
response = MatrixCreateError(
|
|
"M_UNRECOGNIZED",
|
|
"Path /transactions only accepts PUT as a valid method."
|
|
);
|
|
goto end;
|
|
}
|
|
|
|
RequestJSON();
|
|
|
|
events = JsonValueAsArray(HashMapGet(request, "events"));
|
|
for (i = 0; i < ArraySize(events); i++)
|
|
{
|
|
HashMap *event = JsonValueAsObject(ArrayGet(events, i));
|
|
ParseeEventHandler(args->data, event);
|
|
}
|
|
|
|
/* TODO: Store TXN ID somewhere so that we can commit
|
|
* "Epic Matrix Idempotency" */
|
|
|
|
response = HashMapCreate();
|
|
end:
|
|
(void) arr;
|
|
JsonFree(request);
|
|
return response;
|
|
}
|