public async Task InvokeAsync(HttpContext httpContext, IEndpointResolver endpointResolver) { Data.Entities.Endpoint endpoint = await endpointResolver.ResolveAsync(httpContext); if (endpoint != null) { if (!endpoint.DisallowAnonymous || (httpContext.User.Identity.IsAuthenticated && endpoint.EndpointPermissions.All(ep => httpContext.User.HasClaim(PlatformusClaimTypes.Permission, ep.Permission.Code)))) { byte[] responseBody; Func <Task <byte[]> > defaultValueFunc = async() => { IActionResult actionResult = await this.CreateRequestProcessor(endpoint).ProcessAsync(httpContext, endpoint); if (actionResult == null) { return(null); } return(await this.GetResponseBodyAsync(httpContext, actionResult)); }; if (string.IsNullOrEmpty(endpoint.ResponseCacheCSharpClassName)) { responseBody = await defaultValueFunc(); } else { responseBody = await this.CreateResponseCache(endpoint).GetWithDefaultValueAsync( httpContext, defaultValueFunc ); } if (responseBody != null) { await httpContext.Response.Body.WriteAsync(responseBody, 0, responseBody.Length); return; } } } await this.next(httpContext); }