diff options
Diffstat (limited to 'Program.cs')
-rw-r--r-- | Program.cs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using MyDarling.Models; using MyDarling.Services; using Microsoft.AspNetCore.Identity; - +using MyDarling.Controllers; var builder = WebApplication.CreateBuilder(args); @@ -28,6 +28,7 @@ builder.Services.Configure<IdentityOptions>( opts => }); builder.Services.AddTransient<IImageResizer, ImageResizer>(); +builder.Services.AddScoped<IRobotsTxtGenerator, RobotsTxtGenerator>(); builder.Services.AddControllersWithViews(); builder.Services.AddRazorPages(); @@ -38,6 +39,10 @@ app.MapControllers(); app.MapDefaultControllerRoute(); app.MapRazorPages(); +var robotsScope = app.Services.CreateScope(); +var robotsGenerator = robotsScope.ServiceProvider.GetService<IRobotsTxtGenerator>(); +app.MapGet("/robots.txt", () => robotsGenerator!.GetRobotsText()); + app.UseAuthentication(); app.UseAuthorization(); IdentitySeedData.CreateAdminAccount(app.Services, app.Configuration); |