Web Api layout
This commit is contained in:
parent
5619093f41
commit
da6d5576bf
32 changed files with 515 additions and 29 deletions
|
|
@ -1,17 +1,31 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
using InkForge.Api.Data;
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddIdentityApiEndpoints<IdentityUser>()
|
||||
.AddEntityFrameworkStores<ApiDbcontext>()
|
||||
.AddDefaultUI().AddDefaultTokenProviders();
|
||||
var provider = builder.Configuration.GetValue<string>("DbProvider");
|
||||
builder.Services.AddDbContext<ApiDbcontext>(options => _ = provider switch
|
||||
{
|
||||
"Sqlite" => options.UseSqlite(
|
||||
builder.Configuration.GetConnectionString("AuthDb"),
|
||||
x => x.MigrationsAssembly("InkForge.Api.Sqlite")
|
||||
),
|
||||
|
||||
_ => throw new Exception($"Invalid Provider: {provider}")
|
||||
});
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddIdentityApiEndpoints<IdentityUser>()
|
||||
.AddEntityFrameworkStores<ApiDbcontext>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
|
@ -23,11 +37,15 @@ if (app.Environment.IsDevelopment())
|
|||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapIdentityApi<IdentityUser>();
|
||||
|
||||
app.MapControllers();
|
||||
app.MapRazorPages();
|
||||
|
||||
app.Run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue