public async Task Invoke(HttpContext httpContext) { if (httpContext.Request.Path.StartsWithSegments(_path, StringComparison.Ordinal)) { var count = MiddlewareHelpers.GetMultipleQueriesQueryCount(httpContext); var rows = await _db.LoadMultipleQueriesRows(count); var result = JsonConvert.SerializeObject(rows, _jsonSettings); httpContext.Response.StatusCode = StatusCodes.Status200OK; httpContext.Response.ContentType = "application/json"; httpContext.Response.ContentLength = result.Length; await httpContext.Response.WriteAsync(result); return; } await _next(httpContext); }