using Microsoft.AspNetCore.Http;
using SIGCM2.Application.Abstractions;

namespace SIGCM2.Infrastructure.Http;

public sealed class ClientContext : IClientContext
{
    private readonly IHttpContextAccessor _accessor;

    public ClientContext(IHttpContextAccessor accessor)
    {
        _accessor = accessor;
    }

    public string Ip =>
        _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? "0.0.0.0";

    public string? UserAgent =>
        _accessor.HttpContext?.Request?.Headers.UserAgent.ToString();
}
