Skip to content

Commit 55c92a6

Browse files
Merge pull request #176 from AntonioFalcao/feature/graphql-4
Adding dump config mapping
2 parents ade7181 + f3f70af commit 55c92a6

7 files changed

Lines changed: 55 additions & 7 deletions

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"],

src/Dotnet6.GraphQL4.Store.WebMVC/Dotnet6.GraphQL4.Store.WebMVC.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="$(HealthChecks_Version)"/>
9-
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="$(HealthChecks_Version)"/>
8+
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="$(HealthChecks_Version)" />
9+
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="$(HealthChecks_Version)" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="GraphQL.Client" Version="$(GraphQL_Client_Version)"/>
14-
<PackageReference Include="GraphQL.Client.Extensions" Version="3.0.1"/>
15-
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="$(GraphQL_Client_Version)"/>
13+
<PackageReference Include="GraphQL.Client" Version="$(GraphQL_Client_Version)" />
14+
<PackageReference Include="GraphQL.Client.Extensions" Version="3.0.1" />
15+
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="$(GraphQL_Client_Version)" />
1616
</ItemGroup>
1717

1818
</Project>
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/Extensions/EndpointRouteBuilders/EndpointRouteBuilderExtensions.cs renamed to src/Dotnet6.GraphQL4.Store.WebMVC/Extensions/EndpointRouteBuilders/HealthChecksEndpointRouteBuilderExtensions.cs

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

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

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)