UseServerHeader
This commit is contained in:
parent
3d26368839
commit
388db6f061
@ -9,6 +9,21 @@ namespace FastGithub
|
||||
/// </summary>
|
||||
public static class ApplicationBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用服务头
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <param name="serverHeader"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseServerHeader(this IApplicationBuilder app, string serverHeader = nameof(FastGithub))
|
||||
{
|
||||
return app.Use(next => async context =>
|
||||
{
|
||||
await next(context);
|
||||
context.Response.Headers.Server = serverHeader;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用http代理中间件
|
||||
/// </summary>
|
||||
|
||||
@ -57,14 +57,16 @@ namespace FastGithub
|
||||
var httpProxyPort = app.ApplicationServices.GetRequiredService<IOptions<FastGithubOptions>>().Value.HttpProxyPort;
|
||||
app.MapWhen(context => context.Connection.LocalPort == httpProxyPort, appBuilder =>
|
||||
{
|
||||
appBuilder.UseServerHeader();
|
||||
appBuilder.UseHttpProxy();
|
||||
});
|
||||
|
||||
app.MapWhen(context => context.Connection.LocalPort != httpProxyPort, appBuilder =>
|
||||
{
|
||||
appBuilder.UseServerHeader();
|
||||
appBuilder.UseRequestLogging();
|
||||
appBuilder.UseHttpReverseProxy();
|
||||
|
||||
|
||||
appBuilder.UseRouting();
|
||||
appBuilder.UseEndpoints(endpoint =>
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user