allow mapping of secure paths;

This commit is contained in:
2021-08-26 14:35:34 +02:00
parent 10edd74ee2
commit 8f68033ccb
2 changed files with 36 additions and 3 deletions
@@ -51,6 +51,7 @@ namespace zero.Core.Collections
where T : ZeroEntity
where TParameters : CollectionInterceptor.Parameters<T>
{
string typeName = (typeof(T)).Name;
Func<ICollectionInterceptor, Task<InterceptorResult<T>>> func = default;
foreach (InterceptorRegistration registration in ForType(typeof(T)))
@@ -65,7 +66,7 @@ namespace zero.Core.Collections
func = expression.Compile();
}
Logger.LogDebug("Run interceptor {interceptor} before operation {operation}", registration.Name, instruction.Operation);
Logger.LogDebug("Run interceptor {interceptor} for {type}:{operation}", registration.Name, typeName, instruction.Operation);
InterceptorResult<T> result = await func(interceptor);
@@ -115,8 +116,6 @@ namespace zero.Core.Collections
func = expression.Compile();
}
Logger.LogDebug("Run interceptor {interceptor} after operation {operation}", registration.Name, instruction.Operation);
await func(interceptor);
}
}
+34
View File
@@ -13,6 +13,8 @@ namespace zero.Core
public string ContentRoot { get; set; }
public string SecureRoot { get; set; }
public string Media { get; set; }
protected IWebHostEnvironment Env { get; set; }
@@ -42,6 +44,7 @@ namespace zero.Core
IsDebug = isDebug;
WebRoot = env.WebRootPath;
ContentRoot = env.ContentRootPath;
SecureRoot = Path.Combine(ContentRoot, "wwwroot.secure");
Media = Path.Combine(WebRoot, MEDIA_FOLDER);
}
@@ -63,6 +66,16 @@ namespace zero.Core
return Path.Combine(WebRoot, path);
}
/// <summary>
/// Map a secure path
/// </summary>
public string MapSecure(string path)
{
return Path.Combine(SecureRoot, path);
}
/// <summary>
/// Map a path
/// </summary>
@@ -72,6 +85,15 @@ namespace zero.Core
}
/// <summary>
/// Map a secure path
/// </summary>
public string MapSecure(params string[] paths)
{
return Path.Combine(SecureRoot, Path.Combine(paths));
}
/// <summary>
/// Create a directory if it does not exist yet
/// </summary>
@@ -138,6 +160,8 @@ namespace zero.Core
string WebRoot { get; set; }
string SecureRoot { get; set; }
string Media { get; set; }
/// <summary>
@@ -150,11 +174,21 @@ namespace zero.Core
/// </summary>
string Map(string path);
/// <summary>
/// Map a secure path
/// </summary>
string MapSecure(string path);
/// <summary>
/// Map a path
/// </summary>
string Map(params string[] paths);
/// <summary>
/// Map a secure path
/// </summary>
string MapSecure(params string[] paths);
/// <summary>
/// Create a directory if it does not exist yet
/// </summary>