Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
|
de2daa5693 | 1 year ago |
|
8f150d8db0 | 1 year ago |
|
13bb701d1d | 1 year ago |
|
8d50285de5 | 1 year ago |
|
78290912be | 1 year ago |
|
c0afc8a4a3 | 2 years ago |
|
37afa9436d | 2 years ago |
|
1402ae1b95 | 2 years ago |
|
dd0d45f131 | 2 years ago |
|
9707d2ce23 | 2 years ago |
|
5b5fbc4e29 | 2 years ago |
|
c1dbb0c469 | 2 years ago |
|
9a65aae7c1 | 2 years ago |
|
62e10a01c5 | 2 years ago |
|
043826bcaa | 2 years ago |
|
9e74449ef7 | 2 years ago |
|
72b88d04d4 | 2 years ago |
|
80a880ebdc | 2 years ago |
|
c686ee9737 | 2 years ago |
|
9792fb3325 | 2 years ago |
|
911acb9cb6 | 2 years ago |
|
3c174bf47c | 2 years ago |
|
554f254a2c | 2 years ago |
@ -1,26 +1,27 @@
|
|||||||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EXPOSE 443
|
EXPOSE 443
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY ["API_LoL_Project/API_LoL_Project.csproj", "API_LoL_Project/"]
|
COPY ["API_LoL_Project/API_LoL_Project.csproj", "API_LoL_Project/"]
|
||||||
COPY ["StubLib/StubLib.csproj", "StubLib/"]
|
COPY ["StubLib/StubLib.csproj", "StubLib/"]
|
||||||
COPY ["Model/Model.csproj", "Model/"]
|
COPY ["Model/Model.csproj", "Model/"]
|
||||||
COPY ["Shared/Shared.csproj", "Shared/"]
|
COPY ["Shared/Shared.csproj", "Shared/"]
|
||||||
COPY ["DTO/DTO.csproj", "DTO/"]
|
COPY ["DTO/DTO.csproj", "DTO/"]
|
||||||
RUN dotnet restore "API_LoL_Project/API_LoL_Project.csproj"
|
RUN dotnet restore "API_LoL_Project/API_LoL_Project.csproj"
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/API_LoL_Project"
|
WORKDIR "/src/API_LoL_Project"
|
||||||
RUN dotnet build "API_LoL_Project.csproj" -c Release -o /app/build
|
RUN dotnet build "API_LoL_Project.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
RUN dotnet publish "API_LoL_Project.csproj" -c Release -o /app/publish
|
RUN dotnet publish "API_LoL_Project.csproj" -c Release -o /app/publish
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=publish /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
RUN ls -R
|
||||||
ENTRYPOINT ["dotnet", "API_LoL_Project.dll"]
|
ENTRYPOINT ["dotnet", "API_LoL_Project.dll"]
|
@ -1,108 +1,107 @@
|
|||||||
using Business;
|
using Business;
|
||||||
using Entities;
|
using Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||||
using Model;
|
using Model;
|
||||||
using StubLib;
|
using StubLib;
|
||||||
using API_LoL_Project;
|
using API_LoL_Project;
|
||||||
using API_LoL_Project.JsonConverter;
|
using API_LoL_Project.JsonConverter;
|
||||||
using API_LoL_Project.Middleware.Auth;
|
using API_LoL_Project.Middleware.Auth;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
var connectionString = builder.Configuration.GetConnectionString("LolDatabase");
|
var connectionString = builder.Configuration.GetConnectionString("LolDatabase");
|
||||||
builder.Services.AddDbContext<LolDbContext>(options =>
|
builder.Services.AddDbContext<LolDbContext>(options =>
|
||||||
options.UseSqlite(connectionString), ServiceLifetime.Singleton);
|
options.UseSqlite(connectionString), ServiceLifetime.Singleton);
|
||||||
|
|
||||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||||
{
|
{
|
||||||
options.JsonSerializerOptions.Converters.Add(new ReadOnlyDictionaryConverter<string, int>());
|
options.JsonSerializerOptions.Converters.Add(new ReadOnlyDictionaryConverter<string, int>());
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen( cont =>
|
builder.Services.AddSwaggerGen( cont =>
|
||||||
{
|
{
|
||||||
cont.AddSecurityDefinition("ApiKey", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
cont.AddSecurityDefinition("ApiKey", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||||
{
|
{
|
||||||
Description = "The Key to acces to the API",
|
Description = "The Key to acces to the API",
|
||||||
Type = SecuritySchemeType.ApiKey,
|
Type = SecuritySchemeType.ApiKey,
|
||||||
Name = "x-api-key",
|
Name = "x-api-key",
|
||||||
In = ParameterLocation.Header,
|
In = ParameterLocation.Header,
|
||||||
Scheme = "ApiKeyScheme"
|
Scheme = "ApiKeyScheme"
|
||||||
});
|
});
|
||||||
|
|
||||||
var scheme = new OpenApiSecurityScheme
|
var scheme = new OpenApiSecurityScheme
|
||||||
{
|
{
|
||||||
Reference = new OpenApiReference
|
Reference = new OpenApiReference
|
||||||
{
|
{
|
||||||
Type = ReferenceType.SecurityScheme,
|
Type = ReferenceType.SecurityScheme,
|
||||||
Id = "ApiKey"
|
Id = "ApiKey"
|
||||||
},
|
},
|
||||||
In = ParameterLocation.Header
|
In = ParameterLocation.Header
|
||||||
};
|
};
|
||||||
|
|
||||||
var requirement = new OpenApiSecurityRequirement
|
var requirement = new OpenApiSecurityRequirement
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
scheme, new List<string>()
|
scheme, new List<string>()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cont.AddSecurityRequirement(requirement);
|
cont.AddSecurityRequirement(requirement);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.Services.AddApiVersioning(opt =>
|
builder.Services.AddApiVersioning(opt =>
|
||||||
{
|
{
|
||||||
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0);
|
||||||
opt.AssumeDefaultVersionWhenUnspecified = true;
|
opt.AssumeDefaultVersionWhenUnspecified = true;
|
||||||
opt.ReportApiVersions = true;
|
opt.ReportApiVersions = true;
|
||||||
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader());
|
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader());
|
||||||
});
|
});
|
||||||
builder.Services.ConfigureOptions<LolSwaggerOptions>();
|
builder.Services.ConfigureOptions<LolSwaggerOptions>();
|
||||||
builder.Services.AddVersionedApiExplorer(setup =>
|
builder.Services.AddVersionedApiExplorer(setup =>
|
||||||
{
|
{
|
||||||
setup.GroupNameFormat = "'v'VVV";
|
setup.GroupNameFormat = "'v'VVV";
|
||||||
setup.SubstituteApiVersionInUrl = true;
|
setup.SubstituteApiVersionInUrl = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddScoped<AuthMiddlewareFliter>();
|
builder.Services.AddScoped<AuthMiddlewareFliter>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<IDataManager, DbData>();
|
builder.Services.AddSingleton<IDataManager, DbData>();
|
||||||
//builder.Services.AddSingleton<IDataManager, StubData>();
|
//builder.Services.AddSingleton<IDataManager, StubData>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
|
||||||
|
|
||||||
app?.Services?.GetService<LolDbContext>()?.Database.EnsureCreated();
|
app?.Services?.GetService<LolDbContext>()?.Database.EnsureCreated();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
/* app.UseSwaggerUI();*/
|
app.UseSwaggerUI(options =>
|
||||||
app.UseSwaggerUI(options =>
|
{
|
||||||
{
|
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
||||||
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
|
{
|
||||||
{
|
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
||||||
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
|
description.GroupName.ToUpperInvariant());
|
||||||
description.GroupName.ToUpperInvariant());
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
app.UseHttpsRedirection();
|
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
app.UseAuthorization();
|
|
||||||
|
app.MapControllers();
|
||||||
app.MapControllers();
|
|
||||||
|
|
||||||
|
app.Run();
|
||||||
app.Run();
|
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in new issue