-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
47 lines (35 loc) · 1.01 KB
/
Program.cs
File metadata and controls
47 lines (35 loc) · 1.01 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
using Microsoft.EntityFrameworkCore;
using WebApiUsers.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<DbUserContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("connectionDB")));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer(); // <-- Este es vital
builder.Services.AddOpenApi();
builder.Services.AddSwaggerGen();
var app = builder.Build();
//app.MapGet("/", (HttpContext context) =>
//{
// context.Response.Redirect("/swagger/index.html");
// return Task.CompletedTask;
//});
app.Use(async (context, next) =>
{
if(context.Request.Path == "/")
{
context.Response.Redirect("/swagger/index.html", permanent: false);
return;
}
await next();
});
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();