using System;
using Microsoft.AspNetCore.Hosting;
using TwentyTwenty.Mvc;
using TwentyTwenty.Mvc.ErrorHandling;
using TwentyTwenty.Mvc.HealthCheck;
using TwentyTwenty.Mvc.ReadOnlyMode;

namespace Microsoft.AspNetCore.Builder
{
    public static class ErrorHandling
    {
        public static void UseErrorHandling(this IApplicationBuilder app, ICodeMap codeMap)
            => app.UseErrorHandling(codeMap.MapErrorCode);

        public static void UseErrorHandling(this IApplicationBuilder app, Func<int, int> codeMap = null)
        {
            app.UseMiddleware<ErrorHandlerMiddleware>(codeMap);
        }

        public static void UseHealthCheck(this IApplicationBuilder app)
            => app.UseHealthCheck("/status/health-check");

        public static void UseHealthCheck(this IApplicationBuilder app, string path)
        {
            app.Map(path, builder =>
            {
                builder.UseMiddleware<HealthCheckMiddleware>();
            });
        }

        public static void UseReadOnlyMode(this IApplicationBuilder app)
        {
            app.UseMiddleware<ReadOnlyModeMiddleware>();
        }
    }
}
using System;
using Microsoft.AspNetCore.Hosting;
using TwentyTwenty.Mvc;
using TwentyTwenty.Mvc.ErrorHandling;
using TwentyTwenty.Mvc.HealthCheck;
using TwentyTwenty.Mvc.ReadOnlyMode;
using TwentyTwenty.Mvc.Version;

namespace Microsoft.AspNetCore.Builder
{
    public static class ErrorHandling
    {
        public static void UseErrorHandling(this IApplicationBuilder app, ICodeMap codeMap)
            => app.UseErrorHandling(codeMap.MapErrorCode);

        public static void UseErrorHandling(this IApplicationBuilder app, Func<int, int> codeMap = null)
        {
            app.UseMiddleware<ErrorHandlerMiddleware>(codeMap);
        }

        public static void UseHealthCheck(this IApplicationBuilder app)
            => app.UseHealthCheck("/status/health-check");

        public static void UseHealthCheck(this IApplicationBuilder app, string path)
        {
            app.Map(path, builder =>
            {
                builder.UseMiddleware<HealthCheckMiddleware>();
            });
        }

        public static void UseReadOnlyMode(this IApplicationBuilder app)
        {
            app.UseMiddleware<ReadOnlyModeMiddleware>();
        }

        public static void UseVersionHeader(this IApplicationBuilder app, string headerName = "api-version")
        {
            app.UseMiddleware<VersionHeaderMiddleware>(headerName);
        }
    }
}
Add extension method for using version header middleware.
Add extension method for using version header middleware.
