Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6023cf2eb0 | ||
|
|
63dcd0f13f | ||
|
|
22704590f5 |
@@ -4,15 +4,62 @@ namespace SimApi.Configs
|
||||
{
|
||||
public class SimApiOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 启用全部Cors,对于开发前后分离的时候很有用。
|
||||
/// default: true
|
||||
/// </summary>
|
||||
public bool EnableCors { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 启用SimapiAuth,一个简单的基于Header Token的认证方式。
|
||||
/// default: false
|
||||
/// </summary>
|
||||
public bool EnableSimApiAuth { get; set; } = false;
|
||||
public bool EnableSimApiDoc { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 启用在线文档,启用后 访问 /swagger 可以查看对应的api文档。
|
||||
/// default: false
|
||||
/// </summary>
|
||||
public bool EnableSimApiDoc { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用异常拦截,启用后,所有的异常将被通过json反馈。
|
||||
/// default: true
|
||||
/// </summary>
|
||||
public bool EnableSimApiException { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 开启S3兼容的存储系统。
|
||||
/// default: false
|
||||
/// </summary>
|
||||
public bool EnableSimApiStorage { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 开启ForwardHeaders,开启后可以透传负载均衡的Headers
|
||||
/// default: true
|
||||
/// </summary>
|
||||
public bool EnableForwardHeaders { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 将所有的url都格式化为小写字母
|
||||
/// default: true
|
||||
/// </summary>
|
||||
public bool EnableLowerUrl { get; set; } = true;
|
||||
public bool EnableLogger { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 启用格式化的 Console Logger
|
||||
/// default: false
|
||||
/// </summary>
|
||||
public bool EnableLogger { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
|
||||
/// </summary>
|
||||
public SimApiDocOptions SimApiDocOptions { get; set; } = new SimApiDocOptions();
|
||||
|
||||
/// <summary>
|
||||
/// S3兼容的存储系统配置,需要启用 EnableSimApiStorage
|
||||
/// </summary>
|
||||
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new SimApiStorageOptions();
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,23 @@ namespace SimApi.Configs
|
||||
{
|
||||
public class SimApiStorageOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// S3 服务器入口地址
|
||||
/// </summary>
|
||||
public string Endpoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// S3 服务器文件访问地址
|
||||
/// </summary>
|
||||
public string ServeUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// S3服务 Bucket
|
||||
/// </summary>
|
||||
public string Bucket { get; set; }
|
||||
|
||||
public string AccessKey { get; set; }
|
||||
|
||||
public string SecretKey { get; set; }
|
||||
}
|
||||
}
|
||||
+11
-9
@@ -10,11 +10,22 @@ namespace SimApi.Helpers
|
||||
{
|
||||
public static class SimApiUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前CST时间
|
||||
/// </summary>
|
||||
public static DateTime CstNow
|
||||
{
|
||||
get => DateTime.UtcNow.AddHours(8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前秒级时间戳
|
||||
/// </summary>
|
||||
public static double TimestampNow
|
||||
{
|
||||
get => (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测手机号是否正确
|
||||
/// </summary>
|
||||
@@ -58,14 +69,5 @@ namespace SimApi.Helpers
|
||||
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取 CST 当前时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetCstNow()
|
||||
{
|
||||
return CstNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
<Folder Include="Configurations\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Minio" Version="4.0.2" />
|
||||
<PackageReference Include="Minio" Version="4.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.3.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user