feat: add sub path for actual url
This commit is contained in:
22
Endpoint/Common/Services/UrlHelper.cs
Normal file
22
Endpoint/Common/Services/UrlHelper.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Common.Services;
|
||||
|
||||
public static class UrlHelper
|
||||
{
|
||||
public static string CurrentDomain(HttpContext context) =>
|
||||
context.Request.Headers["X-Forwarded-Host"].FirstOrDefault() ?? context.Request.Host.Value;
|
||||
|
||||
private static string CreateSubPath(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return "/";
|
||||
|
||||
return "/" + path.Trim('/') + "/";
|
||||
}
|
||||
|
||||
public static string GetSubPath => CreateSubPath(Environment.GetEnvironmentVariable("ACTUAL_SUB_PATH"));
|
||||
public static string GetSubPathSwagger => CreateSubPath(Environment.GetEnvironmentVariable("SWAGGER_SUB_PATH"));
|
||||
}
|
Reference in New Issue
Block a user