-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (45 loc) · 1.67 KB
/
Program.cs
File metadata and controls
57 lines (45 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.FeatureManagement;
using Microsoft.FeatureManagement.FeatureFilters;
using PedidosApi.Features;
using PedidosApi.Endpoints;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddFeatureManagement()
.AddFeatureFilter<PercentageFilter>()
.AddFeatureFilter<UserIdPercentageFilter>();
builder.Services.AddScoped<DescontoService>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
var ambiente = builder.Environment.EnvironmentName;
// Depois — lê InformationalVersion (preserva 1.3.0, 1.3.0-beta.1, etc.)
var versaoCompleta = typeof(Program).Assembly
.GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? "0.0.0";
// Remove o hash do commit (+abc123...)
var versao = versaoCompleta.Split('+')[0];
options.SwaggerDoc("v1", new()
{
Title = $"PedidosApi — {ambiente}",
Version = versao,
Description = $"""
API de pedidos com Feature Flags e Rollout Gradual.
Ambiente : {ambiente}
Versão : {versao}
Repositório: Azure Repos / PedidosApi
"""
});
});
var app = builder.Build();
// Swagger sempre visível (todos os ambientes)
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "PedidosApi v1");
options.DocumentTitle = $"PedidosApi — {app.Environment.EnvironmentName}";
});
app.MapPedidoEndpoints();
app.Run();
public partial class Program { }