UseServerHeader
This commit is contained in:
parent
3d26368839
commit
388db6f061
@ -9,6 +9,21 @@ namespace FastGithub
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ApplicationBuilderExtensions
|
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>
|
/// <summary>
|
||||||
/// 使用http代理中间件
|
/// 使用http代理中间件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -57,14 +57,16 @@ namespace FastGithub
|
|||||||
var httpProxyPort = app.ApplicationServices.GetRequiredService<IOptions<FastGithubOptions>>().Value.HttpProxyPort;
|
var httpProxyPort = app.ApplicationServices.GetRequiredService<IOptions<FastGithubOptions>>().Value.HttpProxyPort;
|
||||||
app.MapWhen(context => context.Connection.LocalPort == httpProxyPort, appBuilder =>
|
app.MapWhen(context => context.Connection.LocalPort == httpProxyPort, appBuilder =>
|
||||||
{
|
{
|
||||||
|
appBuilder.UseServerHeader();
|
||||||
appBuilder.UseHttpProxy();
|
appBuilder.UseHttpProxy();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.MapWhen(context => context.Connection.LocalPort != httpProxyPort, appBuilder =>
|
app.MapWhen(context => context.Connection.LocalPort != httpProxyPort, appBuilder =>
|
||||||
{
|
{
|
||||||
|
appBuilder.UseServerHeader();
|
||||||
appBuilder.UseRequestLogging();
|
appBuilder.UseRequestLogging();
|
||||||
appBuilder.UseHttpReverseProxy();
|
appBuilder.UseHttpReverseProxy();
|
||||||
|
|
||||||
appBuilder.UseRouting();
|
appBuilder.UseRouting();
|
||||||
appBuilder.UseEndpoints(endpoint =>
|
appBuilder.UseEndpoints(endpoint =>
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user