dotnet-jwt-token-manager/Test/Program.cs

27 lines
677 B
C#

using OpenHarbor.JwtTokenManager;
using OpenHarbor.JwtTokenManager.Abstractions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient();
builder.Services.AddMemoryCache();
builder.Services.AddJwtTokenManager(builder.Configuration, "JwtTokenManager", options =>
{
options.Cache(cacheOptions =>
{
cacheOptions.ExpirationOffset = 30;
});
});
var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/", async (IJwtTokenManagerService jwtTokenManagerService, CancellationToken cancellationToken) =>
{
var response = await jwtTokenManagerService.GetTokenAsync(cancellationToken);
return Results.Ok(response);
});;
app.Run();