Uwaa/HTTP/Routing/FuncEndpoint.cs
2024-11-22 06:40:43 +00:00

24 lines
691 B
C#

namespace Uwaa.HTTP.Routing;
public delegate Task<HttpResponse?> FuncEndpointDelegateAsync(HttpRequest req, HttpClientInfo info);
public delegate HttpResponse? FuncEndpointDelegate(HttpRequest req, HttpClientInfo info);
public class FuncEndpoint : RouterBase
{
public FuncEndpointDelegateAsync Function;
public FuncEndpoint(FuncEndpointDelegateAsync function)
{
Function = function;
}
public override HttpMethod Method => HttpMethod.Any;
public override int Arguments => 0;
protected override Task<HttpResponse?> GetResponseInner(HttpRequest req, HttpClientInfo info, ArraySegment<string> path)
{
return Function(req, info);
}
}