Exemplo n.º 1
0
        /*
         * a Configure method to create the app's request processing pipeline.
         */
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IBulkDataLoadRepository seeder, ILoggerFactory loggerFactory)
        {
            // Handles non-success status codes with empty body
            app.UseExceptionHandler("/errors/500");
            app.UseStatusCodePagesWithReExecute("/errors/{0}");
            //To handle unexpected exception globally, register custome middleware
            app.UseMiddleware <CustomExceptionMiddleware>();

            //Enable CORS with CORS Middleware for convenience
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            //Using authentication
            app.UseAuthentication();

            //Enable JWT Authentication into http header
            app.UseSwaggerUi3(typeof(Startup).GetTypeInfo().Assembly, settings =>
            {
                settings.GeneratorSettings.OperationProcessors.Add(new OperationSecurityScopeProcessor("JWT Token"));
                settings.GeneratorSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("JWT Token",
                                                                                                 new SwaggerSecurityScheme
                {
                    Type        = SwaggerSecuritySchemeType.ApiKey,
                    Name        = "Authorization",
                    Description = "Copy 'Bearer ' + valid JWT token into field",
                    In          = SwaggerSecurityApiKeyLocation.Header
                }));
            });

            //Enable PerformanceLogger as middleware layer by using extention
            app.UsePerformanceLog(new LogOptions());

            loggerFactory.AddSerilog();
            //Data seeding for convenience
            seeder.LoadData();

            app.UseMvc();
        }
Exemplo n.º 2
0
 public DataLoaderController(IBulkDataLoadRepository bulkDataLoadRepository, ILogger <DataLoaderController> logger)
 {
     this.bulkDataLoadRepository = bulkDataLoadRepository;
     this.logger = logger;
 }