using Insight.Infrastructure.Models;
using Microsoft.AspNetCore.Http;
using System.Text.Json;

namespace Insight.Infrastructure
{
    public static class HttpResponseExtensions
    {
        public static void AddPagination<TData>(this HttpResponse response, PagedList<TData> pagelist)
        {
            response.Headers.Add("X-Pagination", JsonSerializer.Serialize(pagelist.Meta as PagedHeaderData, new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            }));
        }
    }
}