private async Task InvokePlayground(HttpResponse httpResponse) { httpResponse.ContentType = "text/html"; httpResponse.StatusCode = 200; var playgroundPageModel = new PlaygroundPageModel(this.settings); var data = Encoding.UTF8.GetBytes(playgroundPageModel.Render()); await httpResponse.Body.WriteAsync(data, 0, data.Length).ConfigureAwait(false); }
private async Task InvokeGraphiQL(HttpResponse httpResponse) { httpResponse.ContentType = "text/html"; httpResponse.StatusCode = 200; // TODO: use RazorPageGenerator when ASP.NET Core 1.1 is out...? var playgroundPageModel = new PlaygroundPageModel(this.settings); var data = Encoding.UTF8.GetBytes(playgroundPageModel.Render()); await httpResponse.Body.WriteAsync(data, 0, data.Length).ConfigureAwait(false); }
private Task InvokePlayground(HttpResponse httpResponse) { httpResponse.ContentType = "text/html"; httpResponse.StatusCode = 200; // Initialize page model if null if (_pageModel == null) { _pageModel = new PlaygroundPageModel(_options); } byte[] data = Encoding.UTF8.GetBytes(_pageModel.Render()); return(httpResponse.Body.WriteAsync(data, 0, data.Length)); }
/// <summary> /// Try to execute the logic of the middleware /// </summary> /// <param name="httpContext">The HttpContext</param> public Task Invoke(HttpContext httpContext) { if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } httpContext.Response.ContentType = "text/html"; httpContext.Response.StatusCode = 200; // Initialize page model if null if (_pageModel == null) { _pageModel = new PlaygroundPageModel(_options); } byte[] data = Encoding.UTF8.GetBytes(_pageModel.Render()); return(httpContext.Response.Body.WriteAsync(data, 0, data.Length)); }