Exemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
            }
            app.UseCors(builder => builder
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin()
                        .AllowCredentials());
            app.UseMvc();
            if (env.IsDevelopment())
            {
                app.UseSwagger();
            }

            app.UseDolittle();

            app.UseDefaultFiles();
            app.UseStaticFiles();

            BoundedContextListener.Start(app.ApplicationServices);
            TextMessageListener.Start(app.ApplicationServices);

            ConfigureCustom(app, env);

            // Keep last
            app.RunAsSinglePageApplication();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Cert verification is not yet fully functional when using Windows OS for the container
            var bypassCertVerification = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            if (!bypassCertVerification)
            {
                InstallCert();
            }

            // Wait until the app unloads or is cancelled
            Environment.SetEnvironmentVariable("KAFKA_BOUNDED_CONTEXT_SEND_TOPICS", "visualization");
            Globals.BoundedContext = new BoundedContext("ingestion");
            var host = Host.CreateBuilder("OCFEV")
                       .Application(application_builder =>
                                    application_builder
                                    .PrefixLocationsWith(Globals.BoundedContext)
                                    .WithStructureStartingWith <BoundedContext>(_ => _
                                                                                .Required.WithChild <Feature>(f => f
                                                                                                              .WithChild <SubFeature>(c => c.Recursive)
                                                                                                              )
                                                                                )
                                    )
                       .Build();

            BoundedContextListener.Start(host.Container);
            host.Container.Get <IDeviceEventConsumer>().Start().Wait();

            var cts = new CancellationTokenSource();

            AssemblyLoadContext.Default.Unloading += (ctx) => cts.Cancel();
            Console.CancelKeyPress += (sender, cpe) => cts.Cancel();
            WhenCancelled(cts.Token).Wait();
        }
Exemplo n.º 3
0
        public static IApplicationBuilder UseCommon(this IApplicationBuilder app, IHostingEnvironment env)
        {
            Internals.ServiceProvider = app.ApplicationServices;

            app.UsedoLittle(env);

            // Relaxed CORS policy for example only
            app.UseCors(builder => builder
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin()
                        .AllowCredentials());
            app.UseMvc();
            app.UseSwagger();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); });
            }

            app.UseDefaultFiles();
            app.UseStaticFiles();

            BoundedContextListener.Start(app.ApplicationServices);
            TextMessageListener.Start(app.ApplicationServices);

            return(app);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            _serviceProvider = app.ApplicationServices;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                });
            }

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseWebSockets(new WebSocketOptions
            {
                KeepAliveInterval = TimeSpan.FromSeconds(120),
                ReceiveBufferSize = 4 * 1024
            });
            app.UseHub <VesselOrientationHub>("/vessel/orientation");

            // Todo: this probably is a bit too lose..
            app.UseCors(builder => builder
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowAnyOrigin()
                        .AllowCredentials());

            app.UseMvc();
            app.UseDolittle();

            BoundedContextListener.Start(app.ApplicationServices);

            app.RunAsSinglePageApplication();
        }