Exemplo n.º 1
0
        public async Task <ActionResult <string> > PerformHealthCheck()
        {
            var healthCheckResponse = await _healthCheckRunner.RunAsync();

            Response.StatusCode = healthCheckResponse.StatusCode;

            return(Content(healthCheckResponse.Serialize(true), healthCheckResponse.ContentType));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invoke the middleware.
        /// </summary>
        /// <param name="context">The HTTP context for the current request.</param>
        public async Task InvokeAsync(HttpContext context)
        {
            var healthCheckResponse = await _healthCheckRunner.RunAsync(context.RequestAborted).ConfigureAwait(false);

            context.Response.StatusCode  = healthCheckResponse.StatusCode;
            context.Response.ContentType = healthCheckResponse.ContentType;

            await context.Response.WriteAsync(healthCheckResponse.Serialize(_indent)).ConfigureAwait(false);

            // Terminal middlewares don't invoke the 'next' delegate.
        }
        /// <inheritdoc/>
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var healthCheckResponse = await _healthCheckRunner.RunAsync(cancellationToken).ConfigureAwait(false);

            var response = new HttpResponseMessage
            {
                StatusCode = (HttpStatusCode)healthCheckResponse.StatusCode,
                Content    = new StringContent(healthCheckResponse.Serialize(_indent), Encoding.UTF8, healthCheckResponse.ContentType)
            };

            return(response);
        }