Skip to content

Commit 6cf031d

Browse files
committed
Refactor HttpClient and update configuration properties
This commit includes significant changes to the HttpClient configuration and the application's configuration properties. The HttpClient for "GameApi" has been replaced with two new HttpClients, `IGamerNameSuggestionClient` and `IGamesClient`, each configured with their respective base addresses "UserApiBase" and "GameApiBase". The "ApiBase" configuration property has been renamed to "GameApiBase" and a new "UserApiBase" property has been added, which is set to "https://localhost:7133/" in the development settings. The `AddHttpClient` calls have been relocated from `AddRazorComponents` to `AddMsalAuthentication` in `Program.cs`. No other changes have been made to the `AddMsalAuthentication` method, and the `IMobileDetectorService` continues to be added as a scoped service. The "DetailedErrors" configuration property remains set to true.
1 parent 4a665c5 commit 6cf031d

6 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/CodeBreaker.Blazor.Client/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
options.UserOptions.NameClaim = "extension_GamerName";
2121
});
2222

23-
builder.Services.AddHttpClient("GameApi", (HttpClient client) =>
24-
client.BaseAddress = new Uri(builder.Configuration.GetRequired("ApiBase")));
25-
//.AddHttpMessageHandler<>(); // TODO
23+
builder.Services.AddHttpClient<IGamerNameSuggestionClient, GamerNameSuggestionClient>(configure =>
24+
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("UserApiBase")));
25+
26+
builder.Services.AddHttpClient<IGamesClient, GamesClient>(configure =>
27+
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("GameApiBase")));
28+
//.AddHttpMessageHandler<>(); // TODO
2629

27-
builder.Services.AddHttpClient<IGamesClient, GamesClient>("GameApi");
2830
builder.Services.AddScoped<IMobileDetectorService, MobileDetectorService>();
2931

3032
var host = builder.Build();
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"DetailedErrors": true
2+
"DetailedErrors": true,
3+
"UserApiBase": "https://localhost:7133/"
34
}

src/CodeBreaker.Blazor.Client/wwwroot/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"ApiBase": "https://gameapis.kindbeach-def2191a.westeurope.azurecontainerapps.io",
2+
"GameApiBase": "https://gameapis.kindbeach-def2191a.westeurope.azurecontainerapps.io",
3+
"UserApiBase": "", // TODO
34
"AzureAdB2C": {
45
"Authority": "https://codebreakertest.b2clogin.com/codebreakertest.onmicrosoft.com/B2C_1_SUSI",
56
"ClientId": "99375d10-1093-4aa7-badc-0b3be474fad6",

src/CodeBreaker.Blazor/Program.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616

1717
builder.Services.AddLocalization();
1818

19-
builder.Services.AddHttpClient("GameApi", configure =>
20-
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("ApiBase")));
19+
builder.Services.AddHttpClient<IGamerNameSuggestionClient, GamerNameSuggestionClient>(configure =>
20+
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("UserApiBase")));
21+
22+
builder.Services.AddHttpClient<IGamesClient, GamesClient>(configure =>
23+
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("GameApiBase")));
2124

22-
builder.Services.AddHttpClient<IGamesClient, GamesClient>("GameApi");
2325
builder.Services.AddScoped<IMobileDetectorService, MobileDetectorService>();
2426

2527
builder.Services.AddCors();
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"DetailedErrors": true
2+
"DetailedErrors": true,
3+
"UserApiBase": "https://localhost:7133"
34
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"ApiBase": "https://gameapis.kindbeach-def2191a.westeurope.azurecontainerapps.io"
2+
"GameApiBase": "https://gameapis.kindbeach-def2191a.westeurope.azurecontainerapps.io",
3+
"UserApiBase": "" // TODO
34
}

0 commit comments

Comments
 (0)