[성현모] AuthApi 분리
This commit is contained in:
59
Projects/WebApi/AuthApi/Controllers/CommonController.cs
Normal file
59
Projects/WebApi/AuthApi/Controllers/CommonController.cs
Normal file
@ -0,0 +1,59 @@
|
||||
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<WebApiConfig>? _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<ConfigService<WebApiConfig>>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request 클라이언트 IP
|
||||
/// </summary>
|
||||
protected virtual string? GetClientIP()
|
||||
{
|
||||
return _httpContextAccessor?.HttpContext?.Connection?.RemoteIpAddress?.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request 클라이언트 Url
|
||||
/// </summary>
|
||||
protected virtual string? GetRequestUrl()
|
||||
{
|
||||
return _httpContextAccessor?.HttpContext?.Request?.Path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request 클라이언트 method: [GET] or [POST]
|
||||
/// </summary>
|
||||
protected virtual string? GetRequestMethod()
|
||||
{
|
||||
return _httpContextAccessor?.HttpContext?.Request?.Method;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 Action(함수) 이름 가져오기
|
||||
/// </summary>
|
||||
protected virtual string GetMethodName([CallerMemberName] string callerMemberName = "")
|
||||
{
|
||||
return callerMemberName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user