main
Peace 11 months ago
parent 37f5386023
commit 8dc81a7971
  1. 16
      AspNetCoreApi/Program.cs
  2. 2
      README.md

@ -25,6 +25,8 @@ namespace AspNetCoreApi
app.UseSwaggerUI(); app.UseSwaggerUI();
} }
// Add Middlewares
app.UseMiddleware<CustomMiddleware1>(); app.UseMiddleware<CustomMiddleware1>();
app.UseMiddleware<CustomMiddleware2>(); app.UseMiddleware<CustomMiddleware2>();
@ -32,6 +34,20 @@ namespace AspNetCoreApi
app.UseAuthorization(); app.UseAuthorization();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/routingtest", async context =>
{
await context.Response.WriteAsync("Hello, World!");
});
endpoints.MapGet("/routingtest/hello/{name}", async context =>
{
var name = context.Request.RouteValues["name"];
await context.Response.WriteAsync($"Hello, {name}!");
});
});
app.MapControllers(); app.MapControllers();

@ -4,3 +4,5 @@
- API Server - API Server
- Middleware
- Routing
Loading…
Cancel
Save