|
5 | 5 | using NetAPI.Features.Posts; |
6 | 6 | using Microsoft.OpenApi.Models; |
7 | 7 | using NetAPI.Common.Api; |
| 8 | +using NetAPI.Features; |
8 | 9 |
|
9 | 10 | [ExcludeFromCodeCoverage] |
10 | 11 | public static class WebAppExtensions |
@@ -61,37 +62,19 @@ private static async Task EnsureDatabaseCreated(this WebApplication app) |
61 | 62 |
|
62 | 63 | private static void AddEndpoints(this WebApplication app) |
63 | 64 | { |
64 | | - app.MapGet("/", () => "Hello, World!"); |
65 | | - // app.MapGet("/health", () => "Healthy"); |
| 65 | + app.MapGet("/", () => "DotNet API Boilerplate"); |
| 66 | + app.MapGet("/health", () => "Healthy"); |
66 | 67 |
|
67 | 68 | // app.MapGet("/secure", () => "You are authenticated!") |
68 | 69 | // .RequireAuthorization(); // Protect this endpoint |
69 | 70 |
|
70 | 71 | // app.MapGet("/admin", () => "Welcome Admin!") |
71 | 72 | // .RequireAuthorization(policy => policy.RequireRole("admin")); |
72 | 73 |
|
73 | | - app.MapPostEndpoints(); |
| 74 | + app.MapFeatureEndpoints(); |
74 | 75 |
|
75 | 76 | } |
76 | 77 |
|
77 | | - private static void MapPostEndpoints(this IEndpointRouteBuilder app) |
78 | | - { |
79 | | - var endpoint = app.MapPublicGroup("/tasks"); |
80 | | - endpoint.MapEndpoint<GetPosts>(); |
81 | | - } |
82 | | - |
83 | | - private static RouteGroupBuilder MapPublicGroup(this IEndpointRouteBuilder app, string? prefix = null) |
84 | | - { |
85 | | - return app.MapGroup(prefix ?? string.Empty) |
86 | | - .AllowAnonymous(); |
87 | | - } |
88 | | - |
89 | | - private static RouteGroupBuilder MapPrivateGroup(this IEndpointRouteBuilder app, string? prefix = null) |
90 | | - { |
91 | | - return app.MapGroup(prefix ?? string.Empty) |
92 | | - .RequireAuthorization(); |
93 | | - } |
94 | | - |
95 | 78 | private static void AppendHeaders(this WebApplication app) |
96 | 79 | { |
97 | 80 | // Prevent Cross-Site Scripting (XSS) & Clickjacking |
|
0 commit comments