From 4fb55ba149c66efe067e584e515b7886d2fd8a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Mon, 13 Sep 2021 13:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub/Startup.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/FastGithub/Startup.cs b/FastGithub/Startup.cs index d57efe7..d4b0d83 100644 --- a/FastGithub/Startup.cs +++ b/FastGithub/Startup.cs @@ -1,7 +1,9 @@ using FastGithub.Configuration; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System.IO; using System.Threading.Tasks; namespace FastGithub @@ -49,11 +51,21 @@ namespace FastGithub app.UseReverseProxy(); app.UseRouting(); - app.UseEndpoints(endpoint => endpoint.MapFallback(context => + app.UseEndpoints(endpoint => { - context.Response.Redirect("https://github.com/dotnetcore/FastGithub"); - return Task.CompletedTask; - })); + endpoint.Map("/", async context => + { + var certFile = $"CACert/{nameof(FastGithub)}.cer"; + context.Response.ContentType = "application/x-x509-ca-cert"; + context.Response.Headers.Add("Content-Disposition", $"attachment;filename={Path.GetFileName(certFile)}"); + await context.Response.SendFileAsync(certFile); + }); + endpoint.MapFallback(context => + { + context.Response.Redirect("https://github.com/dotnetcore/FastGithub"); + return Task.CompletedTask; + }); + }); } } }