Beispiel #1
0
        internal static Task Run(IContext context)
        {
            Startup();

            if (TryHandleAsStaticContent(context))
            {
                return(MakeCompletedTask());
            }

            IDictionary <string, string> variables;
            var handlerType = TableFor(context.Request.HttpMethod).Get(context.Request.Url.AbsolutePath, out variables, context.Request.GetContentType(), context.Request.GetAccept());

            if (handlerType == null)
            {
                return(null);
            }
            var handlerInfo = new HandlerInfo(handlerType, variables, context.Request.HttpMethod);

            foreach (var key in context.Request.QueryString.Keys.Where(k => !string.IsNullOrWhiteSpace(k)))
            {
                handlerInfo.Variables.Add(key, CombineQueryStringValues(context.Request.QueryString[key]));
            }

            var task = PipelineFunctionFactory.Get(handlerInfo.HandlerType, handlerInfo.HttpMethod)(context, handlerInfo);

            return(task ?? MakeCompletedTask());
        }
Beispiel #2
0
        private static void Run <T>(IContext context)
        {
            var runner = new PipelineFunctionFactory(typeof(T)).BuildAsyncRunMethod("GET");
            var info   = new HandlerInfo(typeof(T), "GET");

            try
            {
                runner(context, info).Wait();
            }
            catch (ArgumentNullException)
            {
                // Content-type handling is going to throw an exception here.
            }
        }