public NEventStoreServer(IPersistStreams persistStreams)
        {
            var bootstrapper = new NEventStoreBootstrapper(persistStreams);

            _owinEmbeddedHost =
                OwinEmbeddedHost.Create(app => app.UseNancy(options => options.Bootstrapper = bootstrapper));
        }
Beispiel #2
0
        public OwinHttpServer(InMemoryRavenConfiguration config, DocumentDatabase db = null, bool useHttpServer = true, Action <RavenDBOptions> configure = null)
        {
            startup = new Startup(config, db);
            if (configure != null)
            {
                configure(startup.Options);
            }
            owinEmbeddedHost = OwinEmbeddedHost.Create(app => startup.Configuration(app));

            if (!useHttpServer)
            {
                return;
            }
            server = WebApp.Start("http://+:" + config.Port, app =>  //TODO DH: configuration.ServerUrl doesn't bind properly
            {
                var listener = (HttpListener)app.Properties["System.Net.HttpListener"];
                if (listener != null)
                {
                    new WindowsAuthConfigureHttpListener().Configure(listener, config);
                }
                startup.Configuration(app);
                app.Use(async(context, _) =>
                {
                    context.Response.StatusCode   = 404;
                    context.Response.ReasonPhrase = "Not Found";
                    await context.Response.Body.WriteAsync(NotFoundBody, 0, NotFoundBody.Length);
                });
            });
        }
        public async Task On_exception_then_should_get_status_code_500()
        {
            using (var host = OwinEmbeddedHost.Create(app => app.Run(ctx =>
            {
                throw new Exception("oops");
            })))
            {
                using (var httpClient = new HttpClient(new OwinHttpMessageHandler(host.Invoke)))
                {
                    var response = await httpClient.GetAsync("http://localhost/");

                    response.StatusCode.Should().Be(HttpStatusCode.InternalServerError);
                }
            }
        }
Beispiel #4
0
        public OwinHttpServer(InMemoryRavenConfiguration config, DocumentDatabase db = null, bool useHttpServer = true, Action <RavenDBOptions> configure = null)
        {
            startup = new Startup(config, db);
            if (configure != null)
            {
                configure(startup.Options);
            }
            owinEmbeddedHost = OwinEmbeddedHost.Create(app => startup.Configuration(app));

            if (!useHttpServer)
            {
                return;
            }

            EnableHttpServer(config);
        }
        public async Task Can_get_response()
        {
            using (var host = OwinEmbeddedHost.Create(app => app.Run(ctx =>
            {
                ctx.Response.StatusCode = 200;
                return(Task.Delay(0));
            })))
            {
                using (var httpClient = new HttpClient(new OwinHttpMessageHandler(host.Invoke)))
                {
                    var response = await httpClient.GetAsync("http://localhost/");

                    response.StatusCode.Should().Be(HttpStatusCode.OK);
                }
            }
        }