using Khd.Core.Library.Filter;
using Khd.Core.Library.Swagger;
using Microsoft.Extensions.DependencyInjection;

namespace Khd.Core.Library
{
    public static class LibraryExtensions
    {
        public static void AddLibrary(this IServiceCollection services)
        {
            services.AddControllers(options =>
            {
                //可以定义出参格式
                //options.Filters.Add<ResultFilter>();
                options.Filters.Add<ExceptionFilter>();
            });
            services.AddMvc().AddJsonOptions(option =>
            {
                option.JsonSerializerOptions.IgnoreNullValues = true;
            });
            services.AddLibrarySwagger();
        }
    }
}