Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 0 additions & 106 deletions src/CodeBreaker.Blazor.Client/Configuration/RemoteServiceDiscovery.cs

This file was deleted.

11 changes: 3 additions & 8 deletions src/CodeBreaker.Blazor.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BlazorApplicationInsights;
using Codebreaker.GameAPIs.Client;
using CodeBreaker.Blazor.Client.Configuration;
using CodeBreaker.Blazor.Client.Contracts.Services;
using CodeBreaker.Blazor.Client.Extensions;
using CodeBreaker.Blazor.Client.Services;
Expand All @@ -10,8 +9,6 @@

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Configuration.AddRemoteServiceDiscovery(new Uri (builder.HostEnvironment.BaseAddress));

builder.Services.AddFluentUIComponents();

builder.Services.AddLocalization();
Expand All @@ -33,14 +30,12 @@
builder.Services.AddTransient<AllAuthorizationMessageHandler>();

builder.Services.AddHttpClient<IGamerNameSuggestionClient, GamerNameSuggestionClient>(configure =>
configure.BaseAddress = new Uri("https://gateway/users/public")
)
.ConfigureRemoteServiceDiscovery();
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("UserServicePublicBaseAddress"))
);

builder.Services.AddHttpClient<IGamesClient, GamesClient>(configure =>
configure.BaseAddress = new Uri("https://gateway/games/")
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("GameServiceBaseAddress"))
)
.ConfigureRemoteServiceDiscovery()
.AddHttpMessageHandler<AllAuthorizationMessageHandler>();

builder.Services.AddScoped<IMobileDetectorService, MobileDetectorService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"DetailedErrors": true
"DetailedErrors": true,
"AzureAdB2C:RedirectUri": "http://localhost:5208/authentication/login-callback",
"GameServiceBaseAddress": "http://localhost:5011/games",
"UserServicePublicBaseAddress": "http://localhost:5011/users/public"
}
7 changes: 5 additions & 2 deletions src/CodeBreaker.Blazor.Client/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"AzureAdB2C": {
"Authority": "https://codebreaker3000.b2clogin.com/codebreaker3000.onmicrosoft.com/B2C_1_SUSI",
"ClientId": "558b37b7-0a71-4463-9d3c-d74220b7e5ee",
"ValidateAuthority": false
}
"ValidateAuthority": false,
"RedirectUri": "https://blazor.codebreaker.app/authentication/login-callback"
},
"GameServiceBaseAddress": "https://codebreaker.cninnovation.com/games",
"UserServicePublicBaseAddress": "https://codebreaker.cninnovation.com/users/public"
}
32 changes: 3 additions & 29 deletions src/CodeBreaker.Blazor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CodeBreaker.Blazor.Client.Pages;
using Codebreaker.GameAPIs.Client;
using CodeBreaker.Blazor.Components;
using CodeBreaker.Blazor.Client.Extensions;
using CodeBreaker.Blazor.Client.Services;
using CodeBreaker.Blazor.Client.Contracts.Services;
using Microsoft.FluentUI.AspNetCore.Components;
Expand All @@ -19,11 +20,11 @@

builder.Services.AddHttpClient<IGamerNameSuggestionClient, GamerNameSuggestionClient>(configure =>
configure.BaseAddress =
new Uri("https://userapis") // Utilize Aspire service discovery
new Uri(builder.Configuration.GetRequired("UserServicePublicBaseAddress"))
);

builder.Services.AddHttpClient<IGamesClient, GamesClient>(configure =>
configure.BaseAddress = new Uri("https://gameapis") // Utilize Aspire service discovery
configure.BaseAddress = new Uri(builder.Configuration.GetRequired("GameServiceBaseAddress"))
);

builder.Services.AddScoped<IMobileDetectorService, MobileDetectorService>();
Expand Down Expand Up @@ -57,31 +58,4 @@
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(GamePage).Assembly);

/// <summary>
/// Reads the environment variables for services and returns a mapping of service names to URLs.
/// </summary>
app.MapGet("/service-discovery", () =>
{
var serviceMapping = new Dictionary<string, string>();
var environmentVariables = Environment.GetEnvironmentVariables();

foreach (var key in environmentVariables.Keys)
{
var keyText = key.ToString()!;

// Check if the key is a service URL (e.g. services__gameapis__http)
if (keyText.StartsWith("services__"))
{
// Extract the service name from the key (e.g. gameapis
var serviceName = keyText.Split("__")[1];

// Add the service name and URL to the mapping if it doesn't already exist
if (!serviceMapping.ContainsKey(serviceName))
serviceMapping.Add(serviceName, environmentVariables[key]!.ToString()!);
}
}

return Results.Json(serviceMapping);
});

app.Run();
4 changes: 3 additions & 1 deletion src/CodeBreaker.Blazor/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"DetailedErrors": true
"DetailedErrors": true,
"GameServiceBaseAddress": "http://localhost:5011/games",
"UserServicePublicBaseAddress": "http://localhost:5011/users/public"
}
2 changes: 2 additions & 0 deletions src/CodeBreaker.Blazor/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{
"GameServiceBaseAddress": "https://codebreaker.cninnovation.com/games",
"UserServicePublicBaseAddress": "https://codebreaker.cninnovation.com/users/public"
}