using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;

namespace YGNT.Infrastructure.Helper
{
    public class UriHelper : IUriHelper
    {
        private readonly IHttpContextAccessor _context;

        public UriHelper(IHttpContextAccessor context)
        {
            _context = context;
        }

        public string GetRequestHostUri()
        {
            var uri = new Uri(_context.HttpContext.Request.GetDisplayUrl());
            var builder = new UriBuilder(uri)
            {
                Path = string.Empty,
                Query = string.Empty
            };
            return builder.Uri.AbsoluteUri;
        }
    }
}