Example #1
0
        internal async Task <RouteTree> BuildRouting(IContainer container, JasperGenerationRules generation)
        {
            if (!Enabled)
            {
                return(null);
            }

            var actions = await FindActions(ApplicationAssembly);

            foreach (var methodCall in actions)
            {
                var chain = Routes.AddRoute(methodCall);
                Urls.Register(chain.Route);
            }

            foreach (var policy in _policies)
            {
                policy.Apply(Routes, generation);
            }

            Routes.AssertNoDuplicateRoutes();

            Routes.Seal();

            var tree = new RouteTree(this, generation);

            tree.CompileAll(container);

            return(tree);
        }
Example #2
0
        // Call this from the activator
        internal Task <RouteTree> BuildRouting(IContainer container, JasperGenerationRules generation)
        {
            if (!Enabled)
            {
                return(null);
            }

            return(_findActions.ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    container.GetInstance <IEnvironmentRecorder>().Failure("Failure while trying to discover HTTP route handlers", t.Exception);
                    throw t.Exception;
                }

                try
                {
                    foreach (var policy in _policies)
                    {
                        policy.Apply(Routes, generation);
                    }



                    Routes.AssertNoDuplicateRoutes();

                    var tree = new RouteTree(this, generation);
                    tree.CompileAll(container);


                    return tree;
                }
                catch (Exception e)
                {
                    container.GetInstance <IEnvironmentRecorder>().Failure("Failure while trying to compile the routing tree", e);
                    throw;
                }
            }));
        }