67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
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<PartService>();
|
|
services.AddTransient<NexpartService>();
|
|
services.AddTransient<SecurityService>();
|
|
services.AddTransient<VehicleService>();
|
|
|
|
services.AddCors(o => o.AddPolicy("Default", builder =>
|
|
{
|
|
builder.AllowAnyOrigin()
|
|
.AllowAnyMethod()
|
|
.AllowAnyHeader();
|
|
}));
|
|
|
|
services.AddDbContext<PartSourceContext>(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();
|
|
}
|
|
}
|
|
}
|