mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Add missing file
This commit is contained in:
parent
5025e0dd4d
commit
ca17efbc29
1 changed files with 31 additions and 0 deletions
31
BTCPayServer/Hosting/HeadersOverrideMiddleware.cs
Normal file
31
BTCPayServer/Hosting/HeadersOverrideMiddleware.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using BTCPayServer.Configuration;
|
||||
|
||||
namespace BTCPayServer.Hosting
|
||||
{
|
||||
public class HeadersOverrideMiddleware
|
||||
{
|
||||
RequestDelegate _Next;
|
||||
string overrideXForwardedProto;
|
||||
public HeadersOverrideMiddleware(RequestDelegate next,
|
||||
IConfiguration options)
|
||||
{
|
||||
_Next = next ?? throw new ArgumentNullException(nameof(next));
|
||||
overrideXForwardedProto = options.GetOrDefault<string>("xforwardedproto", null);
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext httpContext)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(overrideXForwardedProto))
|
||||
{
|
||||
httpContext.Request.Headers["X-Forwarded-Proto"] = overrideXForwardedProto;
|
||||
}
|
||||
await _Next(httpContext);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue