Skip to content

Commit

Permalink
Adding Jwt Extension method to program
Browse files Browse the repository at this point in the history
  • Loading branch information
Edrisym committed Nov 15, 2024
1 parent 9424122 commit 37d6646
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 37 deletions.
4 changes: 4 additions & 0 deletions EWallet.Api/EWallet.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
</Content>
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>

</Project>
43 changes: 6 additions & 37 deletions EWallet.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services
.AddCustomAuthentication(builder.Configuration)
.AddCustomAuthorization();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();

var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast")
.WithOpenApi();

app.Run();

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
app.Run();

0 comments on commit 37d6646

Please sign in to comment.