| 1 |
using Blog.Components; |
| 2 |
using Blog.Services; |
| 3 |
|
| 4 |
var builder = WebApplication.CreateBuilder(args); |
| 5 |
|
| 6 |
|
| 7 |
builder.Services.AddRazorComponents(); |
| 8 |
|
| 9 |
builder.Services.AddHttpClient(); |
| 10 |
builder.Services.AddHybridCache(); |
| 11 |
builder.Services.AddHttpClient<BrpService>( |
| 12 |
client => |
| 13 |
{ |
| 14 |
client.BaseAddress = new Uri("https://brp.bes.is/"); |
| 15 |
}); |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
builder.Services.Configure<WarframeOptions>(builder.Configuration.GetSection(WarframeOptions.Section)); |
| 20 |
builder.Services.AddHttpClient(WarframeDropService.ClientName, client => |
| 21 |
{ |
| 22 |
|
| 23 |
client.DefaultRequestHeaders.UserAgent.ParseAdd("bes.is-droptables/1.0 (+https://bes.is/Warframe)"); |
| 24 |
}); |
| 25 |
|
| 26 |
|
| 27 |
builder.Services.AddSingleton<WarframeDropService>(); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
builder.Services.Configure<RvrbOptions>(builder.Configuration.GetSection(RvrbOptions.Section)); |
| 32 |
builder.Services.AddSingleton<RvrbService>(); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
var app = builder.Build(); |
| 38 |
|
| 39 |
|
| 40 |
if (!app.Environment.IsDevelopment()) |
| 41 |
{ |
| 42 |
app.UseExceptionHandler("/Error", createScopeForErrors: true); |
| 43 |
|
| 44 |
app.UseHsts(); |
| 45 |
} |
| 46 |
|
| 47 |
app.UseHttpsRedirection(); |
| 48 |
|
| 49 |
app.UseAntiforgery(); |
| 50 |
|
| 51 |
app.MapStaticAssets(); |
| 52 |
app.MapRazorComponents<App>(); |
| 53 |
|
| 54 |
|
| 55 |
app.MapGet("/api/warframe/names", async (string? q, WarframeDropService drops, CancellationToken cancellationToken) => |
| 56 |
{ |
| 57 |
var status = await drops.GetTablesAsync(cancellationToken).ConfigureAwait(false); |
| 58 |
return status.Tables?.Search(q ?? "", 10) ?? []; |
| 59 |
}); |
| 60 |
|
| 61 |
app.Run(); |