51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
|
|
using IM_API.Configs;
|
|
using IM_API.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace IM_API
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
IConfiguration configuration = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
|
.Build();
|
|
string conStr = builder.Configuration.GetConnectionString("DefaultConnection")!;
|
|
|
|
builder.Services.AddDbContext<IMDbContext>(options =>
|
|
{
|
|
options.UseMySql(conStr,ServerVersion.AutoDetect(conStr));
|
|
});
|
|
builder.Services.AddAllService(configuration);
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|
|
}
|
|
}
|
|
}
|