Adapt endpoints and configuration
This commit is contained in:
		| @@ -1,18 +1,18 @@ | ||||
| using Asp.Versioning; | ||||
| using Azure.Identity; | ||||
| using Core.Blueprint.Logging.Configuration; | ||||
| using Core.Thalos.Adapters.Extensions; | ||||
| using Core.Thalos.Adapters.Helpers; | ||||
| using Core.Thalos.External.ClientConfiguration; | ||||
| using Microsoft.AspNetCore.ResponseCompression; | ||||
| using Microsoft.Extensions.Configuration.AzureAppConfiguration; | ||||
| using OpenTelemetry.Logs; | ||||
| using OpenTelemetry.Resources; | ||||
| using Swashbuckle.AspNetCore.SwaggerUI; | ||||
| using System.IO.Compression; | ||||
| using System.Reflection; | ||||
|  | ||||
| var builder = WebApplication.CreateBuilder(args); | ||||
|  | ||||
| var authSettings = AuthHelper.GetAuthSettings(builder, "thalos_bff"); | ||||
|  | ||||
| builder.Services.ConfigureAuthentication(builder.Configuration, authSettings); | ||||
|  | ||||
| builder.Services.AddEndpointsApiExplorer(); | ||||
| builder.Configuration | ||||
|     .AddUserSecrets(Assembly.GetExecutingAssembly()) | ||||
| @@ -20,6 +20,7 @@ builder.Configuration | ||||
|  | ||||
| builder.Services.AddResponseCompression(); | ||||
| builder.Services.AddProblemDetails(); | ||||
| builder.Services.AddLogs(builder); | ||||
| builder.Services.AddMemoryCache(); | ||||
| builder.Services.AddResponseCaching(configureOptions => { configureOptions.UseCaseSensitivePaths = true; }); | ||||
| builder.Logging.AddOpenTelemetry(options => | ||||
| @@ -80,14 +81,19 @@ builder.Host.ConfigureServices((context, services) => | ||||
|     services.AddResponseCaching(); | ||||
|     services.AddControllers(); | ||||
|     services.AddEndpointsApiExplorer(); | ||||
|     services.AddVersioning(builder.Configuration); | ||||
|     services.AddSwagger(builder.Configuration, "Core.Thalos.BFF.API.xml", authSettings); | ||||
|     services.AddSwaggerGen(); | ||||
|     services.AddLogging(); | ||||
|     services.AddProblemDetails(); | ||||
|     services.AddHttpContextAccessor(); | ||||
|     services.AddTransient<TrackingMechanismExtension>(); // Register the TrackingIdHandler | ||||
|     services.RegisterExternalLayer(builder.Configuration); | ||||
|     services.AddTelemetry(); | ||||
|  | ||||
|     services.AddApiVersioning(options => options.ReportApiVersions = true) | ||||
|                    .AddApiExplorer(options => | ||||
|                    { | ||||
|                        options.GroupNameFormat = "'v'VVV"; | ||||
|                        options.SubstituteApiVersionInUrl = true; | ||||
|                    }); | ||||
| }); | ||||
|  | ||||
| builder.Services.AddCors(options => | ||||
| @@ -107,8 +113,15 @@ var app = builder.Build(); | ||||
|  | ||||
| app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()); | ||||
| app.UseSwagger(); | ||||
| app.UseSwaggerUI(builder.Configuration, authSettings); | ||||
| app.ConfigureSwagger(builder.Configuration); | ||||
| app.UseSwaggerUI(options => | ||||
| { | ||||
|     foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName)) | ||||
|         options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version); | ||||
|  | ||||
|     options.DisplayRequestDuration(); | ||||
|     options.EnableTryItOutByDefault(); | ||||
|     options.DocExpansion(DocExpansion.None); | ||||
| }); | ||||
| app.UseResponseCompression(); | ||||
| app.UseResponseCaching(); | ||||
| app.UseHttpsRedirection(); | ||||
| @@ -118,6 +131,6 @@ app.UseAuthorization(); | ||||
| app.MapControllers(); | ||||
| app.UseHsts(); | ||||
| app.UseAntiforgery(); | ||||
| app.UseHttpLogging(); | ||||
| app.UseLogging(builder.Configuration); | ||||
|  | ||||
| app.Run(); | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales