Redirect root URL to Swagger UI; add required usings
Added several using directives to Program.cs for new dependencies. Updated HTTP pipeline to redirect requests from "/" to "/swagger" when Swagger is enabled, improving developer experience by automatically showing the API documentation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Rewrite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
@@ -67,6 +68,9 @@ try
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
var rewriteOptions = new RewriteOptions().AddRedirect("^$", "swagger");
|
||||
app.UseRewriter(rewriteOptions);
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
Reference in New Issue
Block a user