using Microsoft.AspNetCore.Mvc; using System.Runtime.CompilerServices; using SystemX.Core.Services; using WebApi.Library.Config; namespace AuthApi.Controllers { public class CommonController : ControllerBase { public readonly IServiceProvider _serviceProvider; public readonly IHttpContextAccessor _httpContextAccessor; public readonly ConfigService? _configService; protected static Guid guid { get; private set; } = Guid.NewGuid(); public CommonController(IServiceProvider serviceProvider, IHttpContextAccessor httpContextAccessor) { //provider _serviceProvider = serviceProvider; _httpContextAccessor = httpContextAccessor; //service _configService = _serviceProvider.GetService>(); } /// /// Request 클라이언트 IP /// protected virtual string? GetClientIP() { return _httpContextAccessor?.HttpContext?.Connection?.RemoteIpAddress?.ToString(); } /// /// Request 클라이언트 Url /// protected virtual string? GetRequestUrl() { return _httpContextAccessor?.HttpContext?.Request?.Path; } /// /// Request 클라이언트 method: [GET] or [POST] /// protected virtual string? GetRequestMethod() { return _httpContextAccessor?.HttpContext?.Request?.Method; } /// /// 현재 Action(함수) 이름 가져오기 /// protected virtual string GetMethodName([CallerMemberName] string callerMemberName = "") { return callerMemberName; } } }