public Task <Response> Handle(Request request, ApiHandlerDelegate <Response> next) { //todo: no exception if (string.IsNullOrEmpty(request.Name)) { throw new Exception("Name should not be empty"); } return(next()); }
public async Task <Unit> Handle(Request request, ApiHandlerDelegate <Unit> next) { //todo: no exception if (request.Value1 > 100) { throw new Exception("Value1 cannot be larger than 100"); } await next(); return(Unit.Value); }
public Task <Response2> Handle(Request2 request, ApiHandlerDelegate <Response2> next) => Task.FromResult(new Response2());
public Task Handle(HttpRequest request, HttpResponse response, RouteData routeData, ApiHandlerDelegate <Request2, Response2> apiHandle) => Task.CompletedTask;
public async Task Handle(HttpRequest request, HttpResponse response, RouteData routeData, ApiHandlerDelegate <Request, Response> apiHandle) { var name = routeData.As <string>("name"); var result = await apiHandle(new Request { Name = name }); await response.WriteJson(200, result); }
public async Task Handle(HttpRequest request, HttpResponse response, RouteData routeData, ApiHandlerDelegate <Request, Unit> apiHandle) { var data = request.As <Request>(); await apiHandle(data); await response.WriteJson(200, new { Result = data.Value1 }); }
public Task <TResponse> Handle(TRequest request, ApiHandlerDelegate <TResponse> next) { //open tran return(next()); }