Skip to content

Commit 24f184c

Browse files
author
vp
committed
Add README endpoint for local development and link in index.html
1 parent afa1183 commit 24f184c

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/Presentation.Web.Server/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@
7979
app.UseRuleLogger();
8080
app.UseResultLogger();
8181

82-
app.UseDefaultFiles();
82+
if (app.Environment.IsLocalDevelopment())
83+
{
84+
app.UseDefaultFiles();
85+
}
8386
app.UseStaticFiles();
8487
app.UseRequestCorrelation();
8588
app.UseRequestModuleContext();
@@ -100,6 +103,7 @@
100103
app.MapModules();
101104
app.MapControllers();
102105
app.MapEndpoints();
106+
app.MapReadme();
103107

104108
app.UseConsoleCommandsInteractiveStats();
105109
app.UseConsoleCommandsInteractive();

src/Presentation.Web.Server/ProgramExtensions.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIT-License
1+
// MIT-License
22
// Copyright BridgingIT GmbH - All Rights Reserved
33
// Use of this source code is governed by an MIT-style license that can be
44
// found in the LICENSE file at https://github.com/bridgingit/bitdevkit/license
@@ -196,4 +196,29 @@ public static WebApplication MapHealthChecks(this WebApplication app)
196196

197197
return app;
198198
}
199+
200+
/// <summary>
201+
/// Map README endpoint for local development only
202+
/// </summary>
203+
public static WebApplication MapReadme(this WebApplication app)
204+
{
205+
if (app.Environment.IsLocalDevelopment())
206+
{
207+
app.MapGet("/readme", async (IWebHostEnvironment env) =>
208+
{
209+
var readmePath = Path.Combine(env.ContentRootPath, "..", "..", "README.md");
210+
if (!File.Exists(readmePath))
211+
{
212+
return Results.NotFound("README.md not found");
213+
}
214+
var content = await File.ReadAllTextAsync(readmePath);
215+
return Results.Text(content, "text/markdown");
216+
})
217+
.ExcludeFromDescription()
218+
.WithName("GetReadme")
219+
.WithTags("Documentation");
220+
}
221+
222+
return app;
223+
}
199224
}

src/Presentation.Web.Server/wwwroot/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ <h2>Welcome</h2>
214214
<h2>Quick Start</h2>
215215
<div class="links">
216216
<a href="/scalar" class="btn">Scalar UI</a>
217+
<a href="/readme" class="btn btn-secondary">View README</a>
217218
<a href="/openapi.json" class="btn btn-secondary">OpenAPI Spec</a>
218219
<a href="/health" class="btn btn-secondary">Health Checks</a>
219220
<a href="http://localhost:15349" class="btn btn-secondary">Seq Dashboard</a>

0 commit comments

Comments
 (0)