mirror of
https://github.com/Readarr/Readarr.git
synced 2026-02-01 01:31:50 -05:00
31 lines
788 B
C#
31 lines
788 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
namespace Readarr.Http.Middleware
|
|
{
|
|
public class VersionMiddleware
|
|
{
|
|
private const string VERSIONHEADER = "X-Application-Version";
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|