-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
31 lines (25 loc) · 855 Bytes
/
Program.cs
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
global using FastEndpoints;
global using FastEndpoints.Security;
using ApiWithFastEndpoints.Model;
using System.Configuration;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthenticationJwtBearer(s => s.SigningKey = "The secret used to sign tokens") //add this
.AddAuthorization();
builder.Services.AddFastEndpoints();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services
.Configure<JWTModel>(
builder.Configuration.GetSection("JwtToken"));
//builder.Configuration.GetRequiredSection(nameof(JWTModel)).Bind(mySettings);
var app = builder.Build();
app.UseAuthentication() //add this
.UseAuthorization();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapGet("/", () => "Hello World!");
app.UseFastEndpoints();
app.Run();