public void Configure(IApplicationBuilder app) { var grpc = new MediaTypeHeaderValue("application/grpc"); var internalDispatcher = new InternalDispatcherEndpoint(_mainQueue, _httpMessageHandler); _mainBus.Subscribe(internalDispatcher); app.Map("/health", _statusCheck.Configure) .UseMiddleware <AuthenticationMiddleware>() .UseRouting() .UseWhen(ctx => !(ctx.Request.GetTypedHeaders().ContentType?.IsSubsetOf(grpc)).GetValueOrDefault(false), b => b .UseMiddleware <KestrelToInternalBridgeMiddleware>() .UseMiddleware <AuthorizationMiddleware>() .UseLegacyHttp(internalDispatcher.InvokeAsync, _httpService) ) .UseEndpoints(ep => ep.MapGrpcService <PersistentSubscriptions>()) .UseEndpoints(ep => ep.MapGrpcService <Users>()) .UseEndpoints(ep => ep.MapGrpcService <Streams>()) .UseEndpoints(ep => ep.MapGrpcService <ClusterGossip>()) .UseEndpoints(ep => ep.MapGrpcService <Elections>()) .UseEndpoints(ep => ep.MapGrpcService <Operations>()) .UseEndpoints(ep => ep.MapGrpcService <ClientGossip>()); _subsystems .Aggregate(app, (b, subsystem) => subsystem.Configure(b)); }
public void SetUp(Action <IHttpService> bootstrap = null) { _bus = new InMemoryBus($"bus_{_serverEndPoint.Port}"); var pipelineBus = InMemoryBus.CreateTest(); var queue = new QueuedHandlerThreadPool(pipelineBus, "Test", new QueueStatsManager(), true, TimeSpan.FromMilliseconds(50)); _multiQueuedHandler = new MultiQueuedHandler(new IQueuedHandler[] { queue }, null); _multiQueuedHandler.Start(); _service = new KestrelHttpService(ServiceAccessibility.Private, _bus, new NaiveUriRouter(), _multiQueuedHandler, false, null, 0, false, _serverEndPoint); _internalDispatcher = new InternalDispatcherEndpoint(queue, _multiQueuedHandler); _bus.Subscribe(_internalDispatcher); KestrelHttpService.CreateAndSubscribePipeline(pipelineBus); bootstrap?.Invoke(_service); _server = new TestServer( new WebHostBuilder() .UseStartup(new ClusterVNodeStartup(Array.Empty <ISubsystem>(), queue, _bus, _multiQueuedHandler, new TestAuthenticationProvider(), new IHttpAuthenticationProvider[] { new BasicHttpAuthenticationProvider(new TestAuthenticationProvider()), new AnonymousHttpAuthenticationProvider(), }, new TestAuthorizationProvider(), new FakeReadIndex(_ => false), 1024 * 1024, _service))); _httpMessageHandler = _server.CreateHandler(); _client = new HttpAsyncClient(_timeout, _httpMessageHandler); HttpBootstrap.Subscribe(_bus, _service); }