Пример #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, FinnAirContext context, IOptions <WebServerUrl> webServerSettings, ILoggerFactory loggerFactory, UserManager <IdentityUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }


            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseAuthentication();

            //var swaggerOptions = new SwaggerOptions();
            //Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions);

            app.UseSwagger();
            //app.UseSwaggerUI(option => {
            //    option.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description);
            //});
            var virtualDir = "";

            if (!env.IsDevelopment())
            {
                var webServerUrl = webServerSettings.Value;
                virtualDir = webServerUrl.AppVirtualDir;
            }

            app.UseSwaggerUI(option =>
            {
                option.DocumentTitle = $"FinnAir API ({_apiVersion}) documentation";
                option.SwaggerEndpoint(virtualDir + $"/swagger/{_apiVersion}/swagger.json", $"FinnAir API ({_apiVersion})");
            });

            DbSeeder.SeedDb(userManager);
            loggerFactory.AddFile("Logs/mylog-{Date}.txt");
            app.UseMvc();
        }
Пример #2
0
 public FlightDetailsService(FinnAirContext context)
 {
     this.context = context;
     _disposed    = false;
 }