Skip to content

Commit 7cffb9b

Browse files
authored
Extract InvokeRoute method to allow overriding (#176)
* Extract InvokeRoute method to allow overridingit. * Remove commented code.
1 parent 3036c46 commit 7cffb9b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nanoFramework.WebServer/WebServer.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ private void StartListener()
580580

581581
if (isAuthOk)
582582
{
583-
route.Callback.Invoke(null, new object[] { new WebServerEventArgs(context) });
583+
InvokeRoute(route, context);
584584
}
585585
else
586586
{
@@ -638,6 +638,16 @@ private void StartListener()
638638
}
639639
}
640640

641+
/// <summary>
642+
/// Method which invokes route. Can be overriden to inject custom logic.
643+
/// </summary>
644+
/// <param name="route">Current rounte to invoke. Resolved based on parameters.</param>
645+
/// <param name="context">Context of current request.</param>
646+
protected virtual void InvokeRoute(CallbackRoutes route, HttpListenerContext context)
647+
{
648+
route.Callback.Invoke(null, new object[] { new WebServerEventArgs(context) });
649+
}
650+
641651
private string GetApiKeyFromHeaders(WebHeaderCollection headers)
642652
{
643653
var sec = headers.GetValues("ApiKey");

0 commit comments

Comments
 (0)