예제 #1
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;
        }
예제 #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);
        }
예제 #3
0
        public OwinServiceArguments(RouteData routeData, IDictionary <string, object> environment)
        {
            var httpRequest = new OwinHttpRequest(environment);

            var httpContextBase = new OwinHttpContext(environment);

            Set(environment);

            Set <HttpContextBase>(httpContextBase);

            Set(routeData);

            Set <IHttpRequest>(httpRequest);

            Set <IHttpResponse>(new OwinHttpResponse(environment));

            Set(new OwinContext(environment));

            var log = environment.Log();

            if (log != null)
            {
                Set(log);
            }
        }
예제 #4
0
        public async Task Invoke(IDictionary<string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData = _routes.GetRouteData(owinHttpContext);
            if (routeData == null)
            {
                write404(environment);
                return;
            }


            new OwinRequestReader().Read(environment);

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

            try
            {
                await invoker.Invoke(arguments, routeData.Values).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                write500(environment, e);
            }
        }
예제 #5
0
        public async Task Invoke(IDictionary <string, object> environment)
        {
            var owinHttpContext = new OwinHttpContext(environment);
            var routeData       = _routes.GetRouteData(owinHttpContext);

            if (routeData == null)
            {
                write404(environment);
                return;
            }


            new OwinRequestReader().Read(environment);

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

            try
            {
                await invoker.Invoke(arguments, routeData.Values).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                write500(environment, e);
            }
        }
예제 #6
0
        public OwinServiceArguments(RouteData routeData, IDictionary<string, object> environment)
        {
            var httpRequest = new OwinHttpRequest(environment);

            var httpContextBase = new OwinHttpContext(environment);
            With<HttpContextBase>(httpContextBase);

            With(routeData);

            With<IHttpRequest>(httpRequest);
            With<IHttpResponse>(new OwinHttpResponse(environment));

            With(new OwinContext(environment));
        }
예제 #7
0
        public OwinServiceArguments(RouteData routeData, IDictionary <string, object> environment)
        {
            var httpRequest = new OwinHttpRequest(environment);

            var httpContextBase = new OwinHttpContext(environment);

            With <HttpContextBase>(httpContextBase);

            With(routeData);

            With <IHttpRequest>(httpRequest);

            With <IHttpResponse>(new OwinHttpResponse(environment));

            With(new OwinContext(environment));
        }
예제 #8
0
        public OwinServiceArguments(RouteData routeData, IDictionary<string, object> environment)
        {
            var httpRequest = new OwinHttpRequest(environment);

            var httpContextBase = new OwinHttpContext(environment);

            Set(environment);

            Set<HttpContextBase>(httpContextBase);

            Set(routeData);

            Set<IHttpRequest>(httpRequest);

            Set<IHttpResponse>(new OwinHttpResponse(environment));

            Set(new OwinContext(environment));

            var log = environment.Log();
            if (log != null)
            {
                Set(log);
            }
        }