Uwaa/HTTP/Routing/FuncEndpoint.cs

25 lines
691 B
C#
Raw Permalink Normal View History

2024-11-22 07:40:43 +01:00
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);
}
}