From 526c2364b9ad685d1c000fc8a168bf1305aaa8b7 Mon Sep 17 00:00:00 2001 From: vman Date: Fri, 18 Nov 2022 16:08:51 -0500 Subject: Add project files. --- .../PageRouterEntry.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs (limited to 'VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs') diff --git a/VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs b/VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs new file mode 100644 index 0000000..d89b0e0 --- /dev/null +++ b/VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading.Tasks; +using System.Collections.Generic; + +using VNLib.Utils.Logging; + +namespace VNLib.Plugins.Essentials.Content.Routing +{ + public sealed class PageRouterEntry : PluginBase, IPageRouter + { + public override string PluginName => "Essentials.Router"; + + private Router PageRouter; + public ValueTask RouteAsync(HttpEntity entity) => PageRouter.RouteAsync(entity); + + protected override void OnLoad() + { + try + { + //Init router + PageRouter = new(this); + Log.Information("Plugin loaded"); + } + catch (KeyNotFoundException knf) + { + Log.Error("Plugin failed to load, missing required configuration variables {err}", knf.Message); + } + } + + protected override void OnUnLoad() + { + Log.Information("Plugin unloaded"); + } + + protected override void ProcessHostCommand(string cmd) + { + if(cmd.Contains("reset")) + { + PageRouter?.ResetRoutes(); + Log.Information("Routing table reset"); + } + } + } +} -- cgit