/// <summary>
        /// External HTTP Request called from HTTP handlers
        /// </summary>
        public virtual object Execute(object requestDto, IRequest req)
        {
            req.Dto = requestDto;
            var requestType = requestDto.GetType();

            if (AppHost.Config.EnableAccessRestrictions)
            {
                AssertServiceRestrictions(requestType, req.RequestAttributes);
            }

            var handlerFn = GetService(requestType);

            return(AppHost.OnAfterExecute(req, requestDto, handlerFn(req, requestDto)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute a Service with a Request DTO. See ExecuteAsync for a non-blocking alternative.
        /// </summary>
        public virtual object Execute(object requestDto, IRequest req)
        {
            req.Dto = requestDto;
            var requestType = requestDto.GetType();

            req.OperationName = requestType.Name;

            if (appHost.Config.EnableAccessRestrictions)
            {
                AssertServiceRestrictions(requestType, req.RequestAttributes);
            }

            var handlerFn = GetService(requestType);
            var response  = handlerFn(req, requestDto);

            if (response is Task responseTask)
            {
                response = responseTask.GetResult();
            }

            response = appHost.OnAfterExecute(req, requestDto, response);

            return(response);
        }