Пример #1
0
        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());
        }
Пример #2
0
        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);
        }
Пример #3
0
 public Task <Response2> Handle(Request2 request, ApiHandlerDelegate <Response2> next) => Task.FromResult(new Response2());
Пример #4
0
 public Task Handle(HttpRequest request, HttpResponse response, RouteData routeData, ApiHandlerDelegate <Request2, Response2> apiHandle) => Task.CompletedTask;
Пример #5
0
        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);
        }
Пример #6
0
        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 });
        }
Пример #7
0
 public Task <TResponse> Handle(TRequest request, ApiHandlerDelegate <TResponse> next)
 {
     //open tran
     return(next());
 }