Log API requests and responses to a file

This commit is contained in:
Les De Ridder 2017-08-20 03:08:10 +02:00
parent 4c6d3a5f30
commit 6c745dc60c
1 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,15 @@ void onAPIRequest(HTTPServerRequest request, HTTPServerResponse response)
import std.stdio : writeln;
writeln(apiEndpoint);
import std.file : append;
struct LogEntry
{
string endpoint;
Json request;
Json response;
}
append("api.log", LogEntry(apiEndpoint, requestJson, finalResponseJson).serializeToJson.toPrettyString ~ "\n\n");
}
Json getRequestJson(ubyte[] input, string endpoint, string nonce)