You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
786 B
31 lines
786 B
3 years ago
|
using System.Threading.Tasks;
|
||
|
using Microsoft.AspNetCore.Http;
|
||
|
using NzbDrone.Common.EnvironmentInfo;
|
||
|
|
||
|
namespace Lidarr.Http.Middleware
|
||
|
{
|
||
|
public class VersionMiddleware
|
||
|
{
|
||
|
private const string VERSIONHEADER = "X-ApplicationVersion";
|
||
|
|
||
|
private readonly RequestDelegate _next;
|
||
|
private readonly string _version;
|
||
|
|
||
|
public VersionMiddleware(RequestDelegate next)
|
||
|
{
|
||
|
_next = next;
|
||
|
_version = BuildInfo.Version.ToString();
|
||
|
}
|
||
|
|
||
|
public async Task InvokeAsync(HttpContext context)
|
||
|
{
|
||
|
if (!context.Response.Headers.ContainsKey(VERSIONHEADER))
|
||
|
{
|
||
|
context.Response.Headers.Add(VERSIONHEADER, _version);
|
||
|
}
|
||
|
|
||
|
await _next(context);
|
||
|
}
|
||
|
}
|
||
|
}
|