file-watcher/NancyModules/SyncModule.cs
Mike Phares e6df9ae54e disk-info-helper
selenium-helper (Not fully tested)

sync-helper (Not fully tested)
2025-05-19 09:59:09 -07:00

51 lines
1.6 KiB
C#

using Nancy;
using Nancy.Extensions;
namespace File_Watcher.NancyModules;
public class SyncModule : NancyModule
{
public SyncModule()
{
Get("/bob/v1/sync/", _ =>
{
string? result;
try
{
string query = Request.Url.Query;
IDictionary<string, IEnumerable<string>> collection = Nancy.Helpers.HttpUtility.ParseQueryString(query).ToDictionary();
result = collection is null ? "null" : collection.ToString();
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
});
Post("/bob/v1/sync/", _ =>
{
string result;
// Notification notification;
// ILog log = LogManager.GetLogger(typeof(SyncModule));
// log.Info($"Enter-{nameof(Post)}");
try
{
string body = Request.Body.AsString();
DynamicDictionary form = Request.Form;
Dictionary<string, object> keyValuePairs = form.ToDictionary();
string reply = Helpers.SyncHelper.GetReply(body, keyValuePairs);
result = reply;
}
catch (Exception ex)
{
// log.Fatal($"Exception-{nameof(Post)}{Environment.NewLine}{ex.Message}{Environment.NewLine}{Environment.NewLine}{ex.StackTrace}");
result = ex.Message;
throw;
}
// log.Info($"Return-{nameof(Post)}");
return result;
});
}
}