aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials/src/Middleware
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-05-12 16:55:32 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-05-12 16:55:32 -0400
commit4035c838c1508af0aa7e767a97431a692958ce1c (patch)
tree9c8f719db15364296fb9b18cbe559a001d925d73 /lib/Plugins.Essentials/src/Middleware
parentf4f0d4f74250257991c57bfae74c4852c7e1ae46 (diff)
perf: Utils + http perf mods
Diffstat (limited to 'lib/Plugins.Essentials/src/Middleware')
-rw-r--r--lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs b/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs
index 2ce62b3..c3a85c9 100644
--- a/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs
+++ b/lib/Plugins.Essentials/src/Middleware/MiddlewareController.cs
@@ -33,12 +33,20 @@ namespace VNLib.Plugins.Essentials.Middleware
public async ValueTask<bool> ProcessAsync(HttpEntity entity)
{
+ /*
+ * Loops through the current linkedlist of the current middleware chain. The
+ * chain should remain unmodified after GetCurrentHead() is called.
+ *
+ * Middleware will return a Continue routine to move to the next middleware
+ * node. All other routines mean the processor has responded to the client
+ * itself and must exit control and move to response.
+ */
+
LinkedListNode<IHttpMiddleware>? mwNode = _chain.GetCurrentHead();
//Loop through nodes
while (mwNode != null)
{
- //Invoke mw handler on our event
entity.EventArgs = await mwNode.ValueRef.ProcessAsync(entity);
switch (entity.EventArgs.Routine)
@@ -60,9 +68,14 @@ namespace VNLib.Plugins.Essentials.Middleware
public void PostProcess(HttpEntity entity)
{
- LinkedListNode<IHttpMiddleware>? mwNode = _chain.GetCurrentHead();
+ /*
+ * Middleware nodes may be allowed to inspect, or modify the return
+ * event arguments as the server may not have responded to the client
+ * yet.
+ */
- //Loop through nodes
+ LinkedListNode<IHttpMiddleware>? mwNode = _chain.GetCurrentHead();
+
while (mwNode != null)
{
//Invoke mw handler on our event
@@ -72,6 +85,4 @@ namespace VNLib.Plugins.Essentials.Middleware
}
}
}
-
-
-} \ No newline at end of file
+}