From 6c745dc60c79aa180513f87d10188816ad895206 Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Sun, 20 Aug 2017 03:08:10 +0200 Subject: [PATCH] Log API requests and responses to a file --- source/app.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/app.d b/source/app.d index 4cfb854..31959d8 100644 --- a/source/app.d +++ b/source/app.d @@ -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)