Beispiel #1
0
        public void Configuration(IAppBuilder builder)
        {
            // Configure SignalR DI
            GlobalHost.DependencyResolver.Register(typeof (IDocumentStore), () => _documentStore);

            // Nancy DI container is configured in its bootstrapper
            var sampleBootstrapper = new SampleBootstrapper(_documentStore);

            // Note: it's perfectly viable to have an over-arching single application container
            // and configure signalr and nancy to use it.

            builder
                .MapPath("/fault",
                         faultBuilder => faultBuilder
                            .UseShowExceptions()
                            .UseHandler((request, response) => { throw new Exception("oops!"); }))
                .MapPath("/files",
                         siteBuilder => siteBuilder
                            .UseBasicAuth((user, pass) => Task.FromResult(pass == "damo"))
                            .UseDenyAnonymous()
                            .UseDirectoryBrowser(@"c:\"))
                .MapPath("/scripts", scriptsBuilder => scriptsBuilder.UseFileServer("scripts"))
                .MapPath("/site", siteBuilder => siteBuilder.UseNancy(sampleBootstrapper))
                .MapHubs()
                .UseTestPage();
        }
        public void Configuration(IAppBuilder builder)
        {
            // Configure SignalR DI
            GlobalHost.DependencyResolver.Register(typeof(IDocumentStore), () => _documentStore);

            // Nancy DI container is configured in its bootstrapper
            var sampleBootstrapper = new SampleBootstrapper(_documentStore);

            // Note: it's perfectly viable to have an over-arching single application container
            // and configure signalr and nancy to use it.

            builder
            .MapPath("/fault",
                     faultBuilder => faultBuilder
                     .UseErrorPage(new ErrorPageOptions {
                ShowExceptionDetails = true
            })
                     .UseHandler((request, response) => { throw new Exception("oops!"); }))
            .MapPath("/files",
                     siteBuilder => siteBuilder
                     .UseBasicAuth((user, pass) => Task.FromResult(pass == "damo"))
                     .UseDenyAnonymous()
                     .UseDirectoryBrowser(@"c:\"))
            .MapPath("/scripts", scriptsBuilder => scriptsBuilder.UseFileServer("scripts"))
            .MapPath("/site", siteBuilder => siteBuilder.UseNancy(cfg => cfg.Bootstrapper = sampleBootstrapper))
            .MapSignalR()
            .UseWelcomePage();
        }
Beispiel #3
0
        public void Configuration(IAppBuilder builder)
        {
            // Configure SignalR DI
            var resolver = new DefaultDependencyResolver();

            resolver.Register(typeof(Chat), () => new Chat(_documentStore));
            var hubConfig = new HubConfiguration
            {
                Resolver = resolver
            };

            // Nancy DI container is configured in its bootstrapper
            var sampleBootstrapper = new SampleBootstrapper(_documentStore);

            // Note: it's perfectly viable to have an over-arching single application container
            // and configure signalr and nancy to use it.


            builder
            .Map("/fault",
                 faultBuilder => faultBuilder
                 .UseErrorPage(new ErrorPageOptions {
                ShowExceptionDetails = true
            })
                 .Use((context, next) => { throw new Exception("oops!"); }))
            .Map("/files",
                 siteBuilder =>
            {
                siteBuilder.UseBasicAuthentication("nancy-signalr", (id, secret) =>
                {
                    IEnumerable <Claim> claims = new[] { new Claim("id", id) };
                    return(Task.FromResult(claims));
                });

                var options = new DirectoryBrowserOptions
                {
                    FileSystem = new PhysicalFileSystem(@"c:\")
                };
                // .UseDenyAnonymous()
                siteBuilder.UseDirectoryBrowser(options);
            })
            .UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString("/scripts"),
                FileSystem  = new PhysicalFileSystem("scripts")
            })
            .Map("/site", siteBuilder => siteBuilder.UseNancy(cfg => cfg.Bootstrapper = sampleBootstrapper))
            .MapHubs(hubConfig)
            .UseWelcomePage();
        }