Example #1
0
        // This method is called by the runtime, after the ConfigureServices
        // method above. Use this method to add middleware.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            ICorsSetup corsSetup,
            IApplicationLifetime appLifetime)
        {
            loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));

            // Check for Authorization header before dispatching requests
            app.UseMiddleware <AuthMiddleware>();

            // Enable CORS - Must be before UseMvc
            // see: https://docs.microsoft.com/en-us/aspnet/core/security/cors
            corsSetup.UseMiddleware(app);

            app.UseMvc();

            // Start simulation agent thread
            appLifetime.ApplicationStarted.Register(this.StartAgent);
            appLifetime.ApplicationStopping.Register(this.StopAgent);

            // If you want to dispose of resources that have been resolved in the
            // application container, register for the "ApplicationStopped" event.
            appLifetime.ApplicationStopped.Register(() => this.ApplicationContainer.Dispose());
        }
        // This method is called by the runtime, after the ConfigureServices
        // method above. Use this method to add middleware.
        public void Configure(
            IApplicationBuilder app,
            ICorsSetup corsSetup,
            IHostApplicationLifetime appLifetime)
        {
            // Check for Authorization header before dispatching requests
            app.UseMiddleware <AuthMiddleware>();

            // Enable CORS - Must be before UseMvc
            // see: https://docs.microsoft.com/en-us/aspnet/core/security/cors
            corsSetup.UseMiddleware(app);

            app.UseRouting();
            app.UseEndpoints(endpoints => endpoints.MapControllers());

            // If you want to dispose of resources that have been resolved in the
            // application container, register for the "ApplicationStopped" event.
            appLifetime.ApplicationStopped.Register(() => this.ApplicationContainer.Dispose());
        }
Example #3
0
 public void Configure(
     IApplicationBuilder app,
     ICorsSetup corsSetup,
     IHostApplicationLifetime appLifetime)
 {
     app.UseRouting();
     app.UseSwagger();
     app.UseSwaggerUI(c =>
     {
         c.SwaggerEndpoint("./swagger/v1/swagger.json", "V1");
         c.RoutePrefix = string.Empty;
     });
     app.UseMiddleware <AuthMiddleware>();
     corsSetup.UseMiddleware(app);
     app.UseEndpoints(endpoints =>
     {
         endpoints.MapControllers();
     });
     appLifetime.ApplicationStopped.Register(() => this.ApplicationContainer.Dispose());
 }
Example #4
0
        // This method is called by the runtime, after the ConfigureServices
        // method above. Use this method to add middleware.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            ICorsSetup corsSetup,
            IApplicationLifetime appLifetime)
        {
            loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));

            // Check for Authorization header before dispatching requests
            app.UseMiddleware <AuthMiddleware>();

            // Enable CORS - Must be before UseMvc
            // see: https://docs.microsoft.com/en-us/aspnet/core/security/cors
            corsSetup.UseMiddleware(app);

            app.UseMvc();

            // If you want to dispose of resources that have been resolved in the
            // application container, register for the "ApplicationStopped" event.
            appLifetime.ApplicationStopped.Register(() => this.ApplicationContainer.Dispose());
            // Run a recurring tasks which updates the device properties in CosmosDB every 1 hour
            appLifetime.ApplicationStarted.Register(() => this.ApplicationContainer.Resolve <IRecurringTasks>().Run());
        }