Example #1
0
        public void Configuration(IAppBuilder builder)
        {
            builder.UseAlpha("a", "b");

            builder.UseFunc(app => Alpha.Invoke(app, "a", "b"));

            builder.UseFunc(Alpha.Invoke, "a", "b");

            builder.Use(Beta.Invoke("a", "b"));

            builder.UseFunc(Beta.Invoke, "a", "b");

            builder.UseGamma("a", "b");

            builder.Use(typeof(Gamma), "a", "b");

            builder.UseType <Gamma>("a", "b");

            builder.UseFunc <AppFunc>(app => new Gamma(app, "a", "b").Invoke);

            builder.Use(typeof(Delta), "a", "b");

            builder.UseType <Delta>("a", "b");

            builder.UseFunc <AppFunc>(app => new Delta(app, "a", "b").Invoke);

            builder.Run(this);
        }
        public void Configuration(IAppBuilder builder)
        {
            builder.UseType<AddBreadCrumbMiddleware>("start-of-the-line");

            builder.MapPath("/branch1", builder1 =>
            {
                builder1.UseType<AddBreadCrumbMiddleware>("took-branch1");

                // Nesting paths, e.g. /branch1/branch2
                builder1.MapPath("/branch2", builder2 =>
                {
                    builder2.UseType<AddBreadCrumbMiddleware>("took-branch2");
                    builder2.UseType<DisplayBreadCrumbs>();
                });

                MapIfIE(builder1);
                builder1.UseType<DisplayBreadCrumbs>();
            });

            // Only full segments are matched, so /branch1 does not match /branch100
            builder.MapPath("/branch100", builder1 =>
            {
                builder1.UseType<AddBreadCrumbMiddleware>("took-branch100");
                builder1.UseType<DisplayBreadCrumbs>();
            });

            MapIfIE(builder);

            builder.UseType<AddBreadCrumbMiddleware>("no-branches-taken");
            builder.UseType<DisplayBreadCrumbs>();
        }
Example #3
0
        public void Configuration(IAppBuilder builder)
        {
            builder.UseAlpha("a", "b");

            builder.UseFunc(app => Alpha.Invoke(app, "a", "b"));

            builder.UseFunc(Alpha.Invoke, "a", "b");

            builder.Use(Beta.Invoke("a", "b"));

            builder.UseFunc(Beta.Invoke, "a", "b");

            builder.UseGamma("a", "b");

            builder.Use(typeof(Gamma), "a", "b");

            builder.UseType<Gamma>("a", "b");

            builder.UseFunc<AppFunc>(app => new Gamma(app, "a", "b").Invoke);

            builder.Use(typeof(Delta), "a", "b");

            builder.UseType<Delta>("a", "b");

            builder.UseFunc<AppFunc>(app => new Delta(app, "a", "b").Invoke);

            builder.Run(this);
        }
        public void Configuration(IAppBuilder builder)
        {
            builder.UseType <AddBreadCrumbMiddleware>("start-of-the-line");

            builder.MapPath("/branch1", builder1 =>
            {
                builder1.UseType <AddBreadCrumbMiddleware>("took-branch1");

                // Nesting paths, e.g. /branch1/branch2
                builder1.MapPath("/branch2", builder2 =>
                {
                    builder2.UseType <AddBreadCrumbMiddleware>("took-branch2");
                    builder2.UseType <DisplayBreadCrumbs>();
                });

                MapIfIE(builder1);
                builder1.UseType <DisplayBreadCrumbs>();
            });

            // Only full segments are matched, so /branch1 does not match /branch100
            builder.MapPath("/branch100", builder1 =>
            {
                builder1.UseType <AddBreadCrumbMiddleware>("took-branch100");
                builder1.UseType <DisplayBreadCrumbs>();
            });

            MapIfIE(builder);

            builder.UseType <AddBreadCrumbMiddleware>("no-branches-taken");
            builder.UseType <DisplayBreadCrumbs>();
        }
 public void NoStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseType<BreadCrumbMiddleware>("a", "PreHandlerExecute");
     app.UseType<BreadCrumbMiddleware>("b", "PreHandlerExecute");
     app.UseType<BreadCrumbMiddleware>("c", "PreHandlerExecute");
     app.Run((AppFunc)(environment =>
     {
         string fullBreadCrumb = environment.Get<string>("test.BreadCrumb", string.Empty);
         Assert.Equal("abc", fullBreadCrumb);
         return TaskHelpers.Completed();
     }));
 }
 public void NoStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseType <BreadCrumbMiddleware>("a", "PreHandlerExecute");
     app.UseType <BreadCrumbMiddleware>("b", "PreHandlerExecute");
     app.UseType <BreadCrumbMiddleware>("c", "PreHandlerExecute");
     app.Run((AppFunc)(environment =>
     {
         string fullBreadCrumb = environment.Get <string>("test.BreadCrumb", string.Empty);
         Assert.Equal("abc", fullBreadCrumb);
         return(TaskHelpers.Completed());
     }));
 }
        // Invoked once at startup to configure your application.
        public void Configuration(IAppBuilder builder)
        {
            // Allow directory browsing from a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/browse");
                options.WithPhysicalPath("public");
                options.WithDirectoryBrowsing();
            });

            // Allow file access to a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/non-browse");
                options.WithPhysicalPath("protected");
            });

            // Serve default files out of the specified directory for the root url.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/");
                options.WithPhysicalPath("protected");
                // options.WithDefaultFileNames(new[] { "index.html" }); // Already included by default.
            });

            builder.UseType<ServeSpecificPage>(@"protected\CustomErrorPage.html");
        }
Example #8
0
        public void Configuration(IAppBuilder app)
        {
            // app.UseFilter(req => req.TraceOutput.WriteLine(
            //    "{0} {1}{2} {3}",
            //    req.Method, req.PathBase, req.Path, req.QueryString));

            app.UseErrorPage();
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.UseType<CanonicalRequestPatterns>();

            app.UseFileServer(opt => opt.WithPhysicalPath("Public"));

            app.MapPath("/static-compression", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.WithPhysicalPath("Public");
                }));

            app.MapPath("/danger", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.StaticFileOptions.ServeUnknownFileTypes = true;
                }));

            app.UseDiagnosticsPage("/testpage");
        }
Example #9
0
        public static IAppBuilder UseRequestTracer(this IAppBuilder builder)
        {
            var         builderProperties = new BuilderProperties(builder.Properties);
            TraceSource traceSource       = builderProperties.Get <TraceSource>("host.TraceSource");

            return(builder.UseType <RequestTracer>(traceSource));
        }
Example #10
0
 public void BadStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseType <BreadCrumbMiddleware>("a", "PreHandlerExecute");
     AddStageMarker(app, "Bad");
     app.UseType <BreadCrumbMiddleware>("b", "PreHandlerExecute");
     AddStageMarker(app, "Unknown");
     app.UseType <BreadCrumbMiddleware>("c", "PreHandlerExecute");
     AddStageMarker(app, "random 13169asg635rs4g3rg3");
     app.Run((AppFunc)(environment =>
     {
         string fullBreadCrumb = environment.Get <string>("test.BreadCrumb", string.Empty);
         Assert.Equal("abc", fullBreadCrumb);
         return(TaskHelpers.Completed());
     }));
 }
Example #11
0
        public void Configuration(IAppBuilder app)
        {
            // app.UseFilter(req => req.TraceOutput.WriteLine(
            //    "{0} {1}{2} {3}",
            //    req.Method, req.PathBase, req.Path, req.QueryString));

            app.UseErrorPage();
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.UseType <CanonicalRequestPatterns>();

            app.UseFileServer(opt => opt.WithPhysicalPath("Public"));

            app.MapPath("/static-compression", map => map
                        .UseStaticCompression()
                        .UseFileServer(opt =>
            {
                opt.WithDirectoryBrowsing();
                opt.WithPhysicalPath("Public");
            }));

            app.MapPath("/danger", map => map
                        .UseStaticCompression()
                        .UseFileServer(opt =>
            {
                opt.WithDirectoryBrowsing();
                opt.StaticFileOptions.ServeUnknownFileTypes = true;
            }));

            app.UseDiagnosticsPage("/testpage");
        }
        // Invoked once at startup to configure your application.
        public void Configuration(IAppBuilder builder)
        {
            // Allow directory browsing from a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/browse");
                options.WithPhysicalPath("public");
                options.WithDirectoryBrowsing();
            });

            // Allow file access to a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/non-browse");
                options.WithPhysicalPath("protected");
            });

            // Serve default files out of the specified directory for the root url.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/");
                options.WithPhysicalPath("protected");
                // options.WithDefaultFileNames(new[] { "index.html" }); // Already included by default.
            });

            builder.UseType <ServeSpecificPage>(@"protected\CustomErrorPage.html");
        }
Example #13
0
 public void BadStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseType<BreadCrumbMiddleware>("a", "PreHandlerExecute");
     AddStageMarker(app, "Bad");
     app.UseType<BreadCrumbMiddleware>("b", "PreHandlerExecute");
     AddStageMarker(app, "Unknown");
     app.UseType<BreadCrumbMiddleware>("c", "PreHandlerExecute");
     AddStageMarker(app, "random 13169asg635rs4g3rg3");
     app.Run((AppFunc)(environment =>
     {
         string fullBreadCrumb = environment.Get<string>("test.BreadCrumb", string.Empty);
         Assert.Equal("abc", fullBreadCrumb);
         return TaskHelpers.Completed();
     }));
 }
Example #14
0
        public static IAppBuilder MapHubs(this IAppBuilder builder, string path, HubConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            return(builder.UseType <HubDispatcherHandler>(path, configuration));
        }
Example #15
0
        public static IAppBuilder MapConnection(this IAppBuilder builder, string url, Type connectionType, ConnectionConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            return(builder.UseType <PersistentConnectionHandler>(url, connectionType, configuration));
        }
Example #16
0
        public static void Configuration(IAppBuilder app)
        {
            var staticFileBasePath = Path.Combine(
                Directory.GetCurrentDirectory(),
                @"..\..\..\SignalR.Hosting.AspNet.Samples");

            Directory.SetCurrentDirectory(staticFileBasePath);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                var context = GlobalHost.ConnectionManager.GetConnectionContext<Streaming>();
                var hubContext = GlobalHost.ConnectionManager.GetHubContext<DemoHub>();

                while (true)
                {
                    try
                    {
                        context.Connection.Broadcast(DateTime.Now.ToString());
                        hubContext.Clients.fromArbitraryCode(DateTime.Now.ToString());
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("SignalR error thrown in Streaming broadcast: {0}", ex);
                    }
                    Thread.Sleep(2000);
                }
            });

            app.MapHubs("/signalr");

            app.MapConnection<SendingConnection>("/sending-connection");
            app.MapConnection<TestConnection>("/test-connection");
            app.MapConnection<Raw>("/raw/raw");
            app.MapConnection<Streaming>("/streaming/streaming");

            app.UseType<RedirectFoldersWithoutSlashes>();
            app.UseType<DefaultStaticFileName>("index.htm");
            app.UseType<DefaultStaticFileName>("index.html");
            app.UseType<ExtensionContentType>(".htm", "text/plain");
            app.UseType<ExtensionContentType>(".html", "text/plain");
            app.UseStatic(staticFileBasePath);
        }
Example #17
0
        public static void Configuration(IAppBuilder app)
        {
            var staticFileBasePath = Path.Combine(
                Directory.GetCurrentDirectory(),
                @"..\..\..\SignalR.Hosting.AspNet.Samples");

            Directory.SetCurrentDirectory(staticFileBasePath);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                var context    = GlobalHost.ConnectionManager.GetConnectionContext <Streaming>();
                var hubContext = GlobalHost.ConnectionManager.GetHubContext <DemoHub>();

                while (true)
                {
                    try
                    {
                        context.Connection.Broadcast(DateTime.Now.ToString());
                        hubContext.Clients.fromArbitraryCode(DateTime.Now.ToString());
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("SignalR error thrown in Streaming broadcast: {0}", ex);
                    }
                    Thread.Sleep(2000);
                }
            });

            app.MapHubs("/signalr");

            app.MapConnection <SendingConnection>("/sending-connection");
            app.MapConnection <TestConnection>("/test-connection");
            app.MapConnection <Raw>("/raw/raw");
            app.MapConnection <Streaming>("/streaming/streaming");

            app.UseType <RedirectFoldersWithoutSlashes>();
            app.UseType <DefaultStaticFileName>("index.htm");
            app.UseType <DefaultStaticFileName>("index.html");
            app.UseType <ExtensionContentType>(".htm", "text/plain");
            app.UseType <ExtensionContentType>(".html", "text/plain");
            app.UseStatic(staticFileBasePath);
        }
Example #18
0
        public static IAppBuilder UsePassiveValidator(this IAppBuilder builder)
        {
            IList <string> warnings = new List <string>();

            if (!PassiveValidator.TryValidateProperties(builder.Properties, warnings))
            {
                throw new InvalidOperationException(warnings.Aggregate("builder.Properties are invalid", (a, b) => a + "\r\n" + b));
            }

            if (warnings.Count != 0)
            {
                var builderProperties = new BuilderProperties(builder.Properties);
                var output            = builderProperties.TraceOutput ?? Console.Out;
                output.WriteLine(warnings.Aggregate("builder.Properties are invalid", (a, b) => a + "\r\n" + b));
            }

            return(builder.UseType <PassiveValidator>());
        }
Example #19
0
 public static IAppBuilder MapHubs(this IAppBuilder builder)
 {
     return(builder.UseType <HubDispatcherHandler>());
 }
Example #20
0
 public static IAppBuilder MapConnection(this IAppBuilder builder, string url, Type connectionType, IDependencyResolver resolver)
 {
     return(builder.UseType <PersistentConnectionHandler>(url, connectionType, resolver));
 }
Example #21
0
 public static IAppBuilder MapConnection(this IAppBuilder builder, string url, Type connectionType)
 {
     return(builder.UseType <PersistentConnectionHandler>(url, connectionType));
 }
Example #22
0
 public static IAppBuilder MapConnection <T>(this IAppBuilder builder, string url)
 {
     return(builder.UseType <PersistentConnectionHandler>(url, typeof(T)));
 }
Example #23
0
 public static IAppBuilder UseRequestLogger(this IAppBuilder builder)
 {
     return(builder.UseType <RequestLogger>());
 }
Example #24
0
 public static IAppBuilder UseXSendFile(this IAppBuilder builder)
 {
     return(builder.UseType <XSendFile>());
 }
Example #25
0
 public static IAppBuilder UseCascade(this IAppBuilder builder, params AppFunc[] apps)
 {
     return(builder.UseType <Cascade>(apps.AsEnumerable <AppFunc>()));
 }
Example #26
0
 public static IAppBuilder UseCascade(this IAppBuilder builder, params Action <IAppBuilder>[] apps)
 {
     return(builder.UseType <Cascade>(apps.Select(cfg => builder.BuildNew <AppFunc>(x => cfg(x)))));
 }
Example #27
0
 public static IAppBuilder UseNancy(this IAppBuilder builder, INancyBootstrapper bootstrapper)
 {
     return(builder.UseType <NancyAdapter>(bootstrapper));
 }
Example #28
0
 public static IAppBuilder UseContentType(this IAppBuilder builder, string contentType)
 {
     return(builder.UseType <ContentType>(contentType));
 }
Example #29
0
 public static IAppBuilder UseContentType(this IAppBuilder builder)
 {
     return(builder.UseType <ContentType>());
 }
Example #30
0
 public static IAppBuilder UsePassiveValidator(this IAppBuilder builder)
 {
     return(builder.UseType <PassiveValidator>());
 }
Example #31
0
 public static IAppBuilder UseChunked(this IAppBuilder builder)
 {
     return(builder.UseType <Chunked>());
 }
Example #32
0
        public void Configuration(IAppBuilder app) {

            app.UseType<MyMiddleware>();
        }
Example #33
0
        public static IAppBuilder UseRequestLogger(this IAppBuilder builder)
        {
            TextWriter logger = builder.Properties.Get <TextWriter>(OwinConstants.TraceOutput);

            return(builder.UseType <RequestLogger>(logger));
        }
Example #34
0
 public static IAppBuilder MapHubs(this IAppBuilder builder, string path, IDependencyResolver resolver)
 {
     return(builder.UseType <HubDispatcherHandler>(path, resolver));
 }
Example #35
0
 public static IAppBuilder MapHubs(this IAppBuilder builder)
 {
     return(builder.UseType <HubDispatcherHandler>(GlobalHost.DependencyResolver));
 }
Example #36
0
 public void KnownStagesSpecified(IAppBuilder app)
 {
     app.UseErrorPage();
     app.UseType<BreadCrumbMiddleware>("a", "Authenticate");
     AddStageMarker(app, "Authenticate");
     app.UseType<BreadCrumbMiddleware>("b", "PostAuthenticate");
     AddStageMarker(app, "PostAuthenticate");
     app.UseType<BreadCrumbMiddleware>("c", "Authorize");
     AddStageMarker(app, "Authorize");
     app.UseType<BreadCrumbMiddleware>("d", "PostAuthorize");
     AddStageMarker(app, "PostAuthorize");
     app.UseType<BreadCrumbMiddleware>("e", "ResolveCache");
     AddStageMarker(app, "ResolveCache");
     app.UseType<BreadCrumbMiddleware>("f", "PostResolveCache");
     AddStageMarker(app, "PostResolveCache");
     app.UseType<BreadCrumbMiddleware>("g", "MapHandler");
     AddStageMarker(app, "MapHandler");
     app.UseType<BreadCrumbMiddleware>("h", "PostMapHandler");
     AddStageMarker(app, "PostMapHandler");
     app.UseType<BreadCrumbMiddleware>("i", "AcquireState");
     AddStageMarker(app, "AcquireState");
     app.UseType<BreadCrumbMiddleware>("j", "PostAcquireState");
     AddStageMarker(app, "PostAcquireState");
     app.UseType<BreadCrumbMiddleware>("k", "PreHandlerExecute");
     AddStageMarker(app, "PreHandlerExecute");
     app.Run((AppFunc)(environment =>
     {
         string fullBreadCrumb = environment.Get<string>("test.BreadCrumb", string.Empty);
         Assert.Equal("abcdefghijk", fullBreadCrumb);
         return TaskHelpers.Completed();
     }));
 }
Example #37
0
 public static IAppBuilder MapConnection <T>(this IAppBuilder builder, string url, IDependencyResolver resolver) where T : PersistentConnection
 {
     return(builder.UseType <PersistentConnectionHandler>(url, typeof(T), resolver));
 }
Example #38
0
 public static IAppBuilder UseTrace(this IAppBuilder builder)
 {
     return(builder.UseType <Trace>());
 }
Example #39
0
 public static IAppBuilder UseHeadSuppression(this IAppBuilder builder)
 {
     return(builder.UseType <HeadSuppression>());
 }
Example #40
0
 public void Configuration(IAppBuilder app)
 {
     // TODO: Figure out how to not have this on all the time
     app.UseType<BasicAuthModule>("user", "password");
     app.MapHubs(new HubConfiguration());
 }