Esempio n. 1
0
        // health/almost_healthy
        public IActionResult AlmostHealthy()
        {
            // For the first 10 seconds that the app is alive, the /health/almost_healthy handler returns a status of 200.
            // After that, the handler returns a status of 500.
            var secondsFromStart = Timekeeper.GetSecondsFromStart();

            _logger.LogInformation($"{secondsFromStart} seconds from start...");
            var secondsToWait = 10;

            if (secondsFromStart < secondsToWait)
            {
                _logger.LogInformation($"< {secondsToWait} seconds -> response with 200");
                return(Ok("[lab-05 task #2] - healthy first 10 sec"));
            }
            else
            {
                _logger.LogInformation($"> {secondsToWait} seconds -> response with 500");
                return(StatusCode(500));
            }
        }