Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data
This commit is contained in:
46
Vendor/EmbedIO-3.5.2/Internal/WebModuleCollection.cs
vendored
Normal file
46
Vendor/EmbedIO-3.5.2/Internal/WebModuleCollection.cs
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using EmbedIO.Utilities;
|
||||
using Swan.Logging;
|
||||
|
||||
namespace EmbedIO.Internal
|
||||
{
|
||||
internal sealed class WebModuleCollection : DisposableComponentCollection<IWebModule>
|
||||
{
|
||||
private readonly string _logSource;
|
||||
|
||||
internal WebModuleCollection(string logSource)
|
||||
{
|
||||
_logSource = logSource;
|
||||
}
|
||||
|
||||
internal void StartAll(CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var (name, module) in WithSafeNames)
|
||||
{
|
||||
$"Starting module {name}...".Debug(_logSource);
|
||||
module.Start(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task DispatchRequestAsync(IHttpContext context)
|
||||
{
|
||||
if (context.IsHandled)
|
||||
return;
|
||||
|
||||
var requestedPath = context.RequestedPath;
|
||||
foreach (var (name, module) in WithSafeNames)
|
||||
{
|
||||
var routeMatch = module.MatchUrlPath(requestedPath);
|
||||
if (routeMatch == null)
|
||||
continue;
|
||||
|
||||
$"[{context.Id}] Processing with {name}.".Debug(_logSource);
|
||||
context.GetImplementation().Route = routeMatch;
|
||||
await module.HandleRequestAsync(context).ConfigureAwait(false);
|
||||
if (context.IsHandled)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user