// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ICustomLoggingConfig customLoggingConfig)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            //app.UseHttpsRedirection();

            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            app.UseRouting();

            // Global cors policy
            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            app.Use(async(context, next) => {
                context.Request.EnableBuffering();
                await next();
            });

            app.UseAuthentication();

            app.UseAuthorization();

            // Logging and debugging
            app.UseMiddleware <RequestLoggingMiddleware>();

            // setup custom logging
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.MSSqlServer(
                connectionString: _config.CustomLogging.WriteTo.FirstOrDefault().Args.ConnectionString,
                sinkOptions: customLoggingConfig.GetSinkOpts(),
                columnOptions: customLoggingConfig.GetColumnOptions())
                         .MinimumLevel.Information()
                         .Enrich.WithMachineName()
                         .CreateLogger();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ICustomLoggingConfig customLoggingConfig)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "RabbitMQ.Producer v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.Use(async(context, next) => {
                context.Request.EnableBuffering();
                await next();
            });

            // Logging and debugging
            app.UseMiddleware <RequestLoggingMiddleware>();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // setup custom logging
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.MSSqlServer(
                connectionString: _config.CustomLogging.WriteTo.FirstOrDefault().Args.ConnectionString,
                sinkOptions: customLoggingConfig.GetSinkOpts(),
                columnOptions: customLoggingConfig.GetColumnOptions())
                         .MinimumLevel.Information()
                         .Enrich.WithMachineName()
                         .CreateLogger();
        }