Skip to content

Commit 01fc91d

Browse files
committed
Remove MapConfigurationEndpoint from hosted playground
Config is now delivered via DOM comments in BlazorClientConfiguration.razor, making the HTTP endpoint unnecessary for the hosted model.
1 parent cca0997 commit 01fc91d

File tree

1 file changed

+0
-77
lines changed
  • playground/AspireWithBlazorHosted/AspireWithBlazorHosted.ServiceDefaults

1 file changed

+0
-77
lines changed

playground/AspireWithBlazorHosted/AspireWithBlazorHosted.ServiceDefaults/Extensions.cs

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System.Text.Json.Nodes;
21
using Microsoft.AspNetCore.Builder;
32
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
4-
using Microsoft.AspNetCore.Http;
5-
using Microsoft.AspNetCore.Routing;
6-
using Microsoft.Extensions.Configuration;
73
using Microsoft.Extensions.DependencyInjection;
84
using Microsoft.Extensions.Diagnostics.HealthChecks;
95
using Microsoft.Extensions.Logging;
@@ -17,14 +13,6 @@ public static class Extensions
1713
{
1814
private const string HealthEndpointPath = "/health";
1915
private const string AlivenessEndpointPath = "/alive";
20-
private const string DefaultConfigurationEndpointPath = "/_blazor/_configuration";
21-
22-
private static readonly Dictionary<string, string> s_defaultConfigurationMappings = new()
23-
{
24-
["services"] = "webAssembly:environment",
25-
["OTEL_EXPORTER_OTLP_ENDPOINT"] = "webAssembly:environment",
26-
["OTEL_EXPORTER_OTLP_HEADERS"] = "webAssembly:environment",
27-
};
2816

2917
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
3018
{
@@ -115,71 +103,6 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
115103
});
116104
}
117105

118-
// Map the configuration endpoint for WebAssembly clients
119-
app.MapConfigurationEndpoint(DefaultConfigurationEndpointPath);
120-
121106
return app;
122107
}
123-
124-
public static IEndpointRouteBuilder MapConfigurationEndpoint(this IEndpointRouteBuilder endpoints, string path)
125-
{
126-
return MapConfigurationEndpoint(endpoints, path, s_defaultConfigurationMappings);
127-
}
128-
129-
public static IEndpointRouteBuilder MapConfigurationEndpoint(this IEndpointRouteBuilder endpoints, string path, Dictionary<string, string> mappings)
130-
{
131-
endpoints.MapGet(path, (IConfiguration configuration) =>
132-
{
133-
// If the hosting layer provided a pre-built config response, return it directly.
134-
var preBuilt = configuration["Client:ConfigResponse"];
135-
if (!string.IsNullOrEmpty(preBuilt))
136-
{
137-
return Results.Content(preBuilt, "application/json");
138-
}
139-
140-
var response = new JsonObject();
141-
142-
foreach (var (sourceKey, targetPath) in mappings)
143-
{
144-
var section = configuration.GetSection(sourceKey);
145-
146-
// Check if this is a section with children or a single value
147-
var children = section.AsEnumerable().Where(kvp => !string.IsNullOrEmpty(kvp.Value)).ToList();
148-
149-
if (children.Count == 0)
150-
{
151-
continue;
152-
}
153-
154-
// Get or create the target JsonObject at the specified path
155-
var target = GetOrCreatePath(response, targetPath);
156-
157-
foreach (var (key, value) in children)
158-
{
159-
target[key] = value;
160-
}
161-
}
162-
163-
return Results.Json(response);
164-
});
165-
166-
return endpoints;
167-
}
168-
169-
private static JsonObject GetOrCreatePath(JsonObject root, string path)
170-
{
171-
var segments = path.Split(':');
172-
var current = root;
173-
174-
foreach (var segment in segments)
175-
{
176-
if (!current.ContainsKey(segment))
177-
{
178-
current[segment] = new JsonObject();
179-
}
180-
current = (JsonObject)current[segment]!;
181-
}
182-
183-
return current;
184-
}
185108
}

0 commit comments

Comments
 (0)