Add header for game list (#3)
Co-authored-by: Maxime Adler <madler@sqli.com> Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Net.Http.Json;
|
||||
using GameIdeas.BlazorApp;
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.Resources;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||
@@ -20,7 +22,22 @@ builder.Services.AddHttpClient(
|
||||
client.Timeout = TimeSpan.FromMinutes(3);
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<AuthentificationService>();
|
||||
|
||||
builder.Services.AddSingleton<TranslationService>();
|
||||
builder.Services.AddSingleton<Translations>();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
var app = builder.Build();
|
||||
|
||||
var client = app.Services.GetService<IHttpClientFactory>()?.CreateClient("GameIdeas.WebAPI") ??
|
||||
throw new Exception("Http client not found");
|
||||
var response = await client.GetAsync("api/Translations");
|
||||
var dictionary = await response.Content.ReadFromJsonAsync<Dictionary<string, string>>();
|
||||
|
||||
if (dictionary != null)
|
||||
{
|
||||
app.Services.GetService<TranslationService>()!.Initialize(dictionary);
|
||||
ResourcesKey.Initialize(app.Services.GetService<Translations>()!);
|
||||
}
|
||||
|
||||
await app.RunAsync();
|
||||
Reference in New Issue
Block a user