using Web.Api.Common;
using Web.Api.Extensions;
using MediatR;

namespace Web.Api.Endpoints.Channel;

/// <summary>채널 상세</summary>
internal sealed class Get : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// 채널 상세 정보 조회 (프로필, 구독자 수, 라이브 상태)
        app.MapGet("api/channel/{channelSID}", async (string channelSID, ISender sender, CancellationToken ct) => 
        {
            var result = await sender.Send(new Application.Features.Api.Channel.Get.Query(channelSID), ct);

            return result.Match(
                () => ApiResponse.Ok(result.Value),
                CustomResults.Problem
            );
        })
        .WithTags("Channel");
    }
}