Beispiel #1
0
        private Task InvokeAltair(HttpResponse httpResponse)
        {
            httpResponse.ContentType = "text/html";
            httpResponse.StatusCode  = 200;

            // Initialize page model if null
            if (_pageModel == null)
            {
                _pageModel = new AltairPageModel(_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 AltairPageModel(_options);
            }

            byte[] data = Encoding.UTF8.GetBytes(_pageModel.Render());
            return(httpContext.Response.Body.WriteAsync(data, 0, data.Length));
        }