Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using NLog.Web;
- using NLog.Extensions.Logging;
- using Microsoft.EntityFrameworkCore;
- using DataAccess.Context;
- using Core.CategoriesApi.Containers;
- namespace CategoriesApi
- {
- public class Startup
- {
- public Startup(IConfiguration configuration, IHostingEnvironment env)
- {
- env.ConfigureNLog("nlog.config");
- Configuration = configuration;
- var asdf = Configuration.GetConnectionString("GymAppDatabase");
- }
- public IConfiguration Configuration { get; set; }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddCors(options =>
- {
- options.AddPolicy("CorsPolicy",
- builder => builder.AllowAnyOrigin()
- .AllowAnyMethod()
- .AllowAnyHeader()
- .AllowCredentials());
- });
- services.AddMvc();
- services.Configure<PostgreConnectionStringConfig>( Configuration);
- services.AddDbContext<TrainingsPlanPostgreDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("GymAppDatabase")));
- }
- // 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)
- {
- app.UseCors("CorsPolicy");
- //add NLog to ASP.NET Core
- loggerFactory.AddNLog();
- //add NLog.Web
- app.AddNLogWeb();
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement