namespace Yes.Blog.Endpoints.Admins.Themes { public class DownloadThemeEndpoint : ThemeEndpointScheme, IEndpoint { public void Map(IEndpointRouteBuilder app) => app.MapGet("/themes/{themeName}/download", Handle); public record Request([FromRoute(Name = "themeName")] string ThemeName); private async Task Handle( [AsParameters] Request request, IMediator mediator, IMapper mapper, CancellationToken cancellationToken) { var command = new DownloadThemeCommand(request.ThemeName); var response = await mediator.Send(command, cancellationToken); string contentType = "application/zip"; string fileDownloadName = Path.GetFileName(response.Filepath); return Results.File(response.Filepath, contentType, fileDownloadName); } } }