using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using PartSource.Api.Formatters; using PartSource.Data; using PartSource.Services; namespace PartSource.Api { public class Startup { public IConfiguration Configuration { get; } public Startup(IConfiguration configuration) { Configuration = configuration; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.OutputFormatters.Add(new LiquidTemplateOutputFormatter()); options.EnableEndpointRouting = false; }); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddCors(o => o.AddPolicy("Default", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("PartSourceDatabase")) ); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //else //{ // app.UseHsts(); //} app.UseCors("Default"); // app.UseExceptionHandler("/Error"); // app.UseHttpsRedirection(); app.UseMvc(); } } }