Problem
I was looking for a solution to provide a minimal solution for API key checks with minimal effort.
Solution
ApiKeyMiddleware.cs:
public class ApiKeyMiddleware
{
private readonly RequestDelegate _next;
private const string APIKEYNAME = "ApiKey";
public ApiKeyMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext …