Exemple #1
0
        private static void executeRoute(RouteData routeData, Response response, OwinRequestBody request)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);
            var invoker   = routeData.RouteHandler.As <FubuRouteHandler>().Invoker;

            var exceptionHandlingObserver = new ExceptionHandlingObserver();

            arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver);

            var task = Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values));

            task.ContinueWith(x =>
            {
                try
                {
                    x.FinishProcessingTask(exceptionHandlingObserver);
                }
                catch (Exception ex)
                {
                    write500(response, ex);
                }
                finally
                {
                    response.Finish();
                }
            });
        }
Exemple #2
0
        public Task Invoke(IDictionary <string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData       = _routes.GetRouteData(owinHttpContext);

            if (routeData == null)
            {
                write404(environment);
                return(Task.Factory.StartNew(() => { }));
            }

            new OwinRequestReader().Read(environment);
            var arguments = new OwinServiceArguments(routeData, environment);
            var invoker   = routeData.RouteHandler.As <FubuRouteHandler>().Invoker;

            var taskCompletionSource = new TaskCompletionSource <object>();
            var requestCompletion    = new RequestCompletion();

            requestCompletion.WhenCompleteDo(ex =>
            {
                if (ex != null)
                {
                    //This seems like OWIN should handle the .SetException(ex) with standard error screen formatting?
                    write500(environment, ex);
                }
                taskCompletionSource.SetResult(null);
            });
            arguments.With <IRequestCompletion>(requestCompletion);
            requestCompletion.SafeStart(() => invoker.Invoke(arguments, routeData.Values, requestCompletion));

            return(taskCompletionSource.Task);
        }
        public Task Invoke(IDictionary <string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData       = _routes.GetRouteData(owinHttpContext);

            if (routeData == null)
            {
                write404(environment);
                return(Task.Factory.StartNew(() => { }));
            }

            new OwinRequestReader().Read(environment);
            var arguments = new OwinServiceArguments(routeData, environment);
            var invoker   = routeData.RouteHandler.As <FubuRouteHandler>().Invoker;

            var exceptionHandlingObserver = new ExceptionHandlingObserver();

            arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver);

            return(Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values))
                   .ContinueWith(x =>
            {
                try
                {
                    x.FinishProcessingTask(exceptionHandlingObserver);
                }
                catch (Exception ex)
                {
                    write500(environment, ex);
                }
            }));
        }
Exemple #4
0
        private static void executeRoute(RouteData routeData, Response response, OwinRequestBody request)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);
            var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;

            var exceptionHandlingObserver = new ExceptionHandlingObserver();
            arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver);

            var task = Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values));

            task.ContinueWith(x =>
            {
                try
                {
                    x.FinishProcessingTask(exceptionHandlingObserver);
                }
                catch (Exception ex)
                {
                    write500(response, ex);
                }
                finally
                {
                    response.Finish();
                }
            });
        }
Exemple #5
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData = _routes.GetRouteData(owinHttpContext);
            if (routeData == null)
            {
                write404(environment);
                return Task.Factory.StartNew(() => { });
            }

            new OwinRequestReader().Read(environment);
            var arguments = new OwinServiceArguments(routeData, environment);
            var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;

            var exceptionHandlingObserver = new ExceptionHandlingObserver();
            arguments.Set(typeof(IExceptionHandlingObserver), exceptionHandlingObserver);

            return Task.Factory.StartNew(() => invoker.Invoke(arguments, routeData.Values))
                .ContinueWith(x =>
                {
                    try
                    {
                        x.FinishProcessingTask(exceptionHandlingObserver);
                    }
                    catch (Exception ex)
                    {
                        write500(environment, ex);
                    }
                });
        }
Exemple #6
0
        public Task Invoke(IDictionary<string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData = _routes.GetRouteData(owinHttpContext);
            if (routeData == null)
            {
                write404(environment);
                return Task.Factory.StartNew(() => { });
            }

            new OwinRequestReader().Read(environment);
            var arguments = new OwinServiceArguments(routeData, environment);
            var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;

            var taskCompletionSource = new TaskCompletionSource<object>();
            var requestCompletion = new RequestCompletion();
            requestCompletion.WhenCompleteDo(ex =>
            {
                if (ex != null)
                {
                    //This seems like OWIN should handle the .SetException(ex) with standard error screen formatting?
                    write500(environment, ex);
                }
                taskCompletionSource.SetResult(null);
            });
            arguments.With<IRequestCompletion>(requestCompletion);
            requestCompletion.SafeStart(() => invoker.Invoke(arguments, routeData.Values, requestCompletion));

            return taskCompletionSource.Task;
        }
Exemple #7
0
        private static void executeRoute(RouteData routeData, Response response, OwinRequestBody request)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);
            var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;

            try
            {
                invoker.Invoke(arguments, routeData.Values);
            }
            catch (Exception ex)
            {
                write500(response, ex);
            }
            finally
            {
                response.Finish();
            }
        }
Exemple #8
0
        private static void executeRoute(RouteData routeData, Response response, OwinRequestBody request)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);
            var invoker   = routeData.RouteHandler.As <FubuRouteHandler>().Invoker;

            try
            {
                invoker.Invoke(arguments, routeData.Values);
            }
            catch (Exception ex)
            {
                write500(response, ex);
            }
            finally
            {
                response.Finish();
            }
        }
Exemple #9
0
        private static void executeRoute(Request request, RouteData routeData, Response response, Action <Exception> fault)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);

            var invoker = routeData.RouteHandler.As <FubuRouteHandler>().Invoker;

            try
            {
                invoker.Invoke(arguments, routeData.Values);
            }
            catch (Exception ex)
            {
                response.Status = "500";
                response.Write("FubuMVC has detected an exception\r\n");
                response.Write(ex.ToString());
            }
            finally
            {
                response.Finish();
            }
        }
Exemple #10
0
        private static void executeRoute(Request request, RouteData routeData, Response response, Action<Exception> fault)
        {
            var arguments = new OwinServiceArguments(routeData, request, response);

            var invoker = routeData.RouteHandler.As<FubuRouteHandler>().Invoker;

            try
            {
                invoker.Invoke(arguments, routeData.Values);
            }
            catch (Exception ex)
            {
                response.Status = "500";
                response.Write("FubuMVC has detected an exception\r\n");
                response.Write(ex.ToString());
            }
            finally
            {
                response.Finish();
            }
        }