disk-info-helper
selenium-helper (Not fully tested) sync-helper (Not fully tested)
This commit is contained in:
51
NancyModules/SyncModule.cs
Normal file
51
NancyModules/SyncModule.cs
Normal file
@ -0,0 +1,51 @@
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user