Skip to content

Commit 06d5eca

Browse files
Adding Dump Config mapping
1 parent 3168596 commit 06d5eca

5 files changed

Lines changed: 49 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Routing;
4+
5+
namespace Dotnet6.GraphQL4.Store.WebAPI.Extensions.EndpointRouteBuilders
6+
{
7+
public static class ConfigurationsEndpointRouteBuilderExtensions
8+
{
9+
public static void MapDumpConfig(this IEndpointRouteBuilder endpoints, string pattern, string configInfo, bool isDevelopment)
10+
{
11+
if (isDevelopment is false) return;
12+
13+
endpoints.MapGet(
14+
pattern: pattern,
15+
requestDelegate: context
16+
=> context.Response.WriteAsync(configInfo, context.RequestAborted));
17+
}
18+
}
19+
}

src/Dotnet6.GraphQL4.Store.WebAPI/Extensions/EndpointRouteBuilders/EndpointRouteBuilderExtensions.cs renamed to src/Dotnet6.GraphQL4.Store.WebAPI/Extensions/EndpointRouteBuilders/HealthChecksEndpointRouteBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Dotnet6.GraphQL4.Store.WebAPI.Extensions.EndpointRouteBuilders
1313
{
14-
public static class EndpointRouteBuilderExtensions
14+
public static class HealthChecksEndpointRouteBuilderExtensions
1515
{
1616
private static readonly JsonSerializerOptions SerializerOptions = new() {DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true};
1717
private static readonly HealthCheck HealthCheck = new();

src/Dotnet6.GraphQL4.Store.WebAPI/Startup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public void Configure(IApplicationBuilder app)
4444
.UseEndpoints(endpoints =>
4545
{
4646
endpoints.MapControllers();
47+
48+
endpoints.MapDumpConfig(
49+
pattern: "/dump-config",
50+
configInfo: (_configuration as IConfigurationRoot).GetDebugView(),
51+
isDevelopment: _env.IsDevelopment());
4752

4853
endpoints.MapApplicationHealthChecks(
4954
pattern: _configuration["HealthChecksPatterns:Health"],
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Routing;
4+
5+
namespace Dotnet6.GraphQL4.Store.WebMVC.Extensions.EndpointRouteBuilders
6+
{
7+
public static class ConfigurationsEndpointRouteBuilderExtensions
8+
{
9+
public static void MapDumpConfig(this IEndpointRouteBuilder endpoints, string pattern, string configInfo, bool isDevelopment)
10+
{
11+
if (isDevelopment is false) return;
12+
13+
endpoints.MapGet(
14+
pattern: pattern,
15+
requestDelegate: context
16+
=> context.Response.WriteAsync(configInfo, context.RequestAborted));
17+
}
18+
}
19+
}

src/Dotnet6.GraphQL4.Store.WebMVC/Startup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public void Configure(IApplicationBuilder app)
4747
{
4848
endpoints.MapControllerRoute("default",
4949
"{controller=Home}/{action=Index}/{id?}");
50+
51+
endpoints.MapDumpConfig(
52+
pattern: "/dump-config",
53+
configInfo: (_configuration as IConfigurationRoot).GetDebugView(),
54+
isDevelopment: _env.IsDevelopment());
5055

5156
endpoints.MapApplicationHealthChecks(
5257
pattern: _configuration["HealthChecksPatterns:Health"],

0 commit comments

Comments
 (0)