﻿using System;

namespace Dotnet.Microservice.Health
{
    /// <summary>
    /// Represents a health check response
    /// </summary>
    public struct HealthResponse
    {
        public readonly bool IsHealthy;
        public readonly string Message;

        private HealthResponse(bool isHealthy, string statusMessage)
        {
            IsHealthy = isHealthy;
            Message = statusMessage;
        }

        public static HealthResponse Healthy()
        {
            return Healthy("OK");
        }

        public static HealthResponse Healthy(string message)
        {
            return new HealthResponse(true, message);
        }

        public static HealthResponse Unhealthy()
        {
            return Unhealthy("FAILED");
        }

        public static HealthResponse Unhealthy(string message)
        {
            return new HealthResponse(false, message);
        }

        public static HealthResponse Unhealthy(Exception exception)
        {
            var message = $"EXCEPTION: {exception.GetType().Name}, {exception.Message}";
            return new HealthResponse(false, message);
        }

    }
}

﻿using System;

namespace Dotnet.Microservice.Health
{
    /// <summary>
    /// Represents a health check response
    /// </summary>
    public struct HealthResponse
    {
        public readonly bool IsHealthy;
        public readonly object Response;

        private HealthResponse(bool isHealthy, object statusObject)
        {
            IsHealthy = isHealthy;
            Response = statusObject;
        }

        public static HealthResponse Healthy()
        {
            return Healthy("OK");
        }

        public static HealthResponse Healthy(object response)
        {
            return new HealthResponse(true, response);
        }

        public static HealthResponse Unhealthy()
        {
            return Unhealthy("FAILED");
        }

        public static HealthResponse Unhealthy(object response)
        {
            return new HealthResponse(false, response);
        }

        public static HealthResponse Unhealthy(Exception exception)
        {
            var message = $"EXCEPTION: {exception.GetType().Name}, {exception.Message}";
            return new HealthResponse(false, message);
        }

    }
}

Allow the status to be any object instead of just a string.
Allow the status to be any object instead of just a string.
