Example #1
0
        public void static_file_middle_ware_is_added_by_default()
        {
            var settings = new OwinSettings();

            settings.Middleware.OfType <MiddlewareNode <StaticFileMiddleware> >()
            .Count().ShouldEqual(1);
        }
Example #2
0
        public void create_with_no_html_head_injection()
        {
            var settings = new OwinSettings();

            settings.Middleware.OfType <MiddlewareNode <HtmlHeadInjectionMiddleware> >()
            .Any().ShouldBeFalse();
        }
        public void static_file_middle_ware_is_added_by_default()
        {
            var settings = new OwinSettings();

            settings.Middleware.OfType<MiddlewareNode<StaticFileMiddleware>>()
                .Count().ShouldBe(1);
        }
Example #4
0
 public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null)
 {
     settings = settings ?? runtime.Factory.Get<OwinSettings>();
     var host = new FubuOwinHost(runtime.Routes);
     AppFunc inner = host.Invoke;
     AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Factory);
     return appFunc;
 }
Example #5
0
        public void create_with_no_html_head_injection()
        {
            PackageRegistry.Properties.ClearAll();

            var settings = new OwinSettings();

            settings.Middleware.OfType <MiddlewareNode <HtmlHeadInjectionMiddleware> >()
            .Any().ShouldBeFalse();
        }
Example #6
0
        public static AppFunc ToAppFunc(FubuRuntime runtime, OwinSettings settings = null)
        {
            settings = settings ?? runtime.Get<OwinSettings>();
            var host = new FubuOwinHost(runtime.Routes);
            AppFunc inner = host.Invoke;
            AppFunc appFunc = settings.BuildAppFunc(inner, runtime.Get<IServiceFactory>());

            var diagnostics = runtime.Get<DiagnosticsSettings>();
            return diagnostics.WrapAppFunc(runtime, appFunc);
        }
Example #7
0
        public void create_with_html_head_injection()
        {
            FubuMode.SetUpForDevelopmentMode();

            PackageRegistry.Properties[HtmlHeadInjectionMiddleware.TEXT_PROPERTY] =
                new HtmlTag("script").Attr("foo", "bar").ToString();

            var settings = new OwinSettings();

            settings.Middleware.OfType <MiddlewareNode <HtmlHeadInjectionMiddleware> >()
            .Any().ShouldBeTrue();
        }
Example #8
0
        public static Action<IAppBuilder> ToStartup(OwinSettings settings, IList<RouteBase> routes)
        {
            return builder =>
            {
                settings.As<IAppBuilderConfiguration>()
                    .Configure(builder);

                var host = new FubuOwinHost(routes);

                builder.Use((object)(Func<object, object>)(ignored => (object) host), new object[0]);
            };
        }
        public static void ApplyInjection(OwinSettings settings)
        {
            if (!FubuMode.InDevelopment()) return;

            var injectedContent = PackageRegistry.Properties[TEXT_PROPERTY];
            if (injectedContent.IsNotEmpty())
            {
                settings.AddMiddleware<HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
                {
                    Content = _ => injectedContent
                });
            }
        }
 public static void ApplyInjection(OwinSettings settings)
 {
     if (FubuMode.InDevelopment() || FubuMode.Mode().EqualsIgnoreCase("diagnostics"))
     {
         var injectedContent = PackageRegistry.Properties[TEXT_PROPERTY];
         if (injectedContent.IsNotEmpty())
         {
             settings.AddMiddleware <HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
             {
                 Content = _ => injectedContent
             });
         }
     }
 }
 public static void ApplyInjection(OwinSettings settings)
 {
     if (FubuMode.InDevelopment() || FubuMode.Mode().EqualsIgnoreCase("diagnostics"))
     {
         var injectedContent = PackageRegistry.Properties[TEXT_PROPERTY];
         if (injectedContent.IsNotEmpty())
         {
             settings.AddMiddleware<HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
             {
                 Content = _ => injectedContent
             });
         }
     }
 }
        public static void ApplyInjection(OwinSettings settings)
        {
            if (!FubuMode.InDevelopment())
            {
                return;
            }

            var injectedContent = PackageRegistry.Properties[TEXT_PROPERTY];

            if (injectedContent.IsNotEmpty())
            {
                settings.AddMiddleware <HtmlHeadInjectionMiddleware>().Arguments.With(new InjectionOptions
                {
                    Content = _ => injectedContent
                });
            }
        }
Example #13
0
        private void startServer(OwinSettings settings, IList <RouteBase> routes, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl

            // Adding the static middleware
            settings.AddMiddleware <StaticFileMiddleware>(_services.GetInstance <IFubuApplicationFiles>(), settings);

            if (physicalPath != null)
            {
                FubuMvcPackageFacility.PhysicalRootPath = physicalPath;
            }
            Action <IAppBuilder> startup = FubuOwinHost.ToStartup(settings, routes);

            var context = new StartContext(parameters)
            {
                Startup = startup,
            };

            settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower();
            context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary());

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            try
            {
                _server = engine.Start(context);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied"))
                {
                    throw new KatanaRightsException(e.InnerException);
                }

                throw;
            }
        }
Example #14
0
        private void startServer(OwinSettings settings, string physicalPath, int port)
        {
            var parameters = new StartOptions {
                Port = port
            };

            parameters.Urls.Add("http://*:" + port); //for netsh http add urlacl


            if (physicalPath != null)
            {
                FubuMvcPackageFacility.PhysicalRootPath = physicalPath;
            }

            var context = new StartContext(parameters)
            {
                App = FubuOwinHost.ToAppFunc(_runtime, settings),
            };

            settings.EnvironmentData.ToDictionary().Each(pair => context.EnvironmentData.Add(pair));


            settings.EnvironmentData[OwinConstants.AppMode] = FubuMode.Mode().ToLower();
            context.EnvironmentData.AddRange(settings.EnvironmentData.ToDictionary());

            var engine = new HostingEngine(new AppBuilderFactory(), new TraceOutputFactory(),
                                           new AppLoader(new IAppLoaderFactory[0]),
                                           new ServerFactoryLoader(new ServerFactoryActivator(new ServiceProvider())));

            try
            {
                _server = engine.Start(context);
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("Access is denied"))
                {
                    throw new KatanaRightsException(e.InnerException);
                }

                throw;
            }
        }
 public void create_with_no_html_head_injection()
 {
     var settings = new OwinSettings();
     settings.Middleware.OfType<MiddlewareNode<HtmlHeadInjectionMiddleware>>()
         .Any().ShouldBeFalse();
 }
Example #16
0
 public StaticFileMiddleware(Func<IDictionary<string, object>, Task> inner, IFubuApplicationFiles files, OwinSettings settings)
     : base(inner)
 {
     _files = files;
     _settings = settings;
 }
 public MiddlewareDeactivator(OwinSettings settings)
 {
     _settings = settings;
 }
Example #18
0
 public StaticFileMiddleware(AppFunc inner, IFubuApplicationFiles files, OwinSettings settings) : base(inner)
 {
     _files    = files;
     _settings = settings;
 }
Example #19
0
 public MiddlewareDeactivator(OwinSettings settings)
 {
     _settings = settings;
 }