Beispiel #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory
                              , IOptions <AppSettings> options, LogToDB logToDB)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }


            loggerFactory.AddSerilog();
            app.UseRequestResponseLogger(options, logToDB);
            app.UseMvc();

            app.UseSwaggerUi3WithApiExplorer(settings =>
            {
                settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase;
                settings.PostProcess = document =>
                {
                    document.Info.Version        = "v1";
                    document.Info.Title          = "Balance Enquiry API";
                    document.Info.TermsOfService = "None";
                };
                settings.GeneratorSettings.OperationProcessors.Add(new OperationSecurityScopeProcessor("Authorization"));
                settings.GeneratorSettings.DocumentProcessors.Add(new SecurityDefinitionAppender("Authorization", new NSwag.SwaggerSecurityScheme()
                {
                    Type        = NSwag.SwaggerSecuritySchemeType.ApiKey,
                    Name        = "Authorization",
                    In          = NSwag.SwaggerSecurityApiKeyLocation.Header,
                    Description = "Bearer token"
                }));
            });
        }
Beispiel #2
0
        public ILogger GetLogger(ObjectType objectType)
        {
            ILogger logger = null;

            switch (objectType)
            {
            case ObjectType.CONSOLE:
                logger = new LogToConsole();
                break;

            case ObjectType.FILE:
                logger = new LogToFile();
                break;

            case ObjectType.DATABASE:
                logger = new LogToDB();
                break;

            default:
                logger = new LogToFile();
                break;
            }

            return(logger);
        }
Beispiel #3
0
 public Logger(RequestDelegate next, ILogger <Logger> logger
               , IOptions <AppSettings> settings, LogToDB logToDB, IAntiforgery antiforgery)
 {
     _next        = next;
     _settings    = settings;
     _logger      = logger;
     _logToDB     = logToDB;
     _antiforgery = antiforgery;
 }
Beispiel #4
0
 public static IApplicationBuilder UseRequestResponseLogger(this IApplicationBuilder builder
                                                            , IOptions <AppSettings> options, LogToDB logToDB)
 {
     return(builder.UseMiddleware <Logger>(options, logToDB));
 }