Loading Api/Middleware/ClacksMiddleware.cs 0 → 100644 +22 −0 Original line number Diff line number Diff line using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; namespace Kafe.Api.Middleware; public class ClacksMiddleware : IMiddleware { public const string HeaderName = "X-Clacks-Overhead"; public const string HeaderValue = "GNU Terry Pratchett"; public async Task InvokeAsync(HttpContext context, RequestDelegate next) { context.Response.OnStarting(() => { context.Response.Headers.TryAdd(HeaderName, HeaderValue); return Task.CompletedTask; }); await next(context); } } Api/Startup.cs +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ using Npgsql; using System.Globalization; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.DependencyInjection.Extensions; using Kafe.Api.Middleware; namespace Kafe.Api; Loading Loading @@ -220,10 +221,13 @@ public class Startup services.RemoveAll<IProblemDetailsWriter>(); services.AddSingleton<IProblemDetailsWriter, KafeProblemDetailsWriter>(); services.AddSingleton<IProblemDetailsService, KafeProblemDetailsService>(); services.AddSingleton<ClacksMiddleware>(); } public void Configure(IApplicationBuilder app) { app.UseMiddleware<ClacksMiddleware>(); app.UseForwardedHeaders(); app.UseHttpsRedirection(); Loading Web/nginx.conf +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ http { sendfile on; keepalive_timeout 65; add_header 'Cache-Control' "no-cache"; add_header 'X-Clacks-Overhead' "GNU Terry Pratchett"; server { listen 80; Loading Loading
Api/Middleware/ClacksMiddleware.cs 0 → 100644 +22 −0 Original line number Diff line number Diff line using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; namespace Kafe.Api.Middleware; public class ClacksMiddleware : IMiddleware { public const string HeaderName = "X-Clacks-Overhead"; public const string HeaderValue = "GNU Terry Pratchett"; public async Task InvokeAsync(HttpContext context, RequestDelegate next) { context.Response.OnStarting(() => { context.Response.Headers.TryAdd(HeaderName, HeaderValue); return Task.CompletedTask; }); await next(context); } }
Api/Startup.cs +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ using Npgsql; using System.Globalization; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.DependencyInjection.Extensions; using Kafe.Api.Middleware; namespace Kafe.Api; Loading Loading @@ -220,10 +221,13 @@ public class Startup services.RemoveAll<IProblemDetailsWriter>(); services.AddSingleton<IProblemDetailsWriter, KafeProblemDetailsWriter>(); services.AddSingleton<IProblemDetailsService, KafeProblemDetailsService>(); services.AddSingleton<ClacksMiddleware>(); } public void Configure(IApplicationBuilder app) { app.UseMiddleware<ClacksMiddleware>(); app.UseForwardedHeaders(); app.UseHttpsRedirection(); Loading
Web/nginx.conf +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ http { sendfile on; keepalive_timeout 65; add_header 'Cache-Control' "no-cache"; add_header 'X-Clacks-Overhead' "GNU Terry Pratchett"; server { listen 80; Loading