aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs
diff options
context:
space:
mode:
Diffstat (limited to 'VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs')
-rw-r--r--VNLib.Plugins.Essentials.Content.Routing/PageRouterEntry.cs44
1 files changed, 44 insertions, 0 deletions
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<FileProcessArgs> 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");
+ }
+ }
+ }
+}