mhf-server/Mhf.Server/Web/Middleware/WebMiddlewareStack.cs
2019-11-24 19:43:35 +08:00

29 lines
717 B
C#

using System;
using System.Threading.Tasks;
namespace Mhf.Server.Web.Middleware
{
/// <summary>
/// Implementation of a middleware
/// </summary>
public class WebMiddlewareStack
{
private WebMiddlewareDelegate _webMiddlewareDelegate;
public WebMiddlewareStack(WebMiddlewareDelegate kernel)
{
_webMiddlewareDelegate = kernel;
}
public Task<WebResponse> Start(WebRequest request)
{
return _webMiddlewareDelegate(request);
}
public void Use(Func<WebMiddlewareDelegate, WebMiddlewareDelegate> middleware)
{
_webMiddlewareDelegate = middleware(_webMiddlewareDelegate);
}
}
}