Files
simapi-net/Configurations/SimApiOptions.cs
T

101 lines
2.7 KiB
C#
Raw Normal View History

using System;
2024-08-19 03:39:35 +08:00
using SimApi.CoceSdk;
2024-04-16 06:57:56 +08:00
namespace SimApi.Configurations;
2024-03-23 07:29:43 +08:00
public class SimApiOptions
{
2024-03-23 07:29:43 +08:00
/// <summary>
/// 启用全部Cors,对于开发前后分离的时候很有用。
/// default: true
/// </summary>
public bool EnableCors { get; set; } = true;
/// <summary>
2024-04-16 06:57:56 +08:00
/// 启用SimApiAuth,一个简单的基于Header Token的认证方式。
2024-03-23 07:29:43 +08:00
/// default: false
/// </summary>
2024-08-03 19:19:42 +08:00
public bool EnableSimApiAuth { get; set; }
2024-03-23 07:29:43 +08:00
2024-08-19 03:39:35 +08:00
/// <summary>
/// 是否使用CoceSdk
/// </summary>
public bool EnableCoceSdk { get; set; }
public CoceAppSdkOption CoceSdkOptions { get; set; } = new();
2024-03-23 07:29:43 +08:00
/// <summary>
/// 启用在线文档,启用后 访问 /swagger 可以查看对应的api文档。
/// default: false
/// </summary>
2024-08-03 19:19:42 +08:00
public bool EnableSimApiDoc { get; set; }
2024-03-23 07:29:43 +08:00
/// <summary>
/// 启用异常拦截,启用后,所有的异常将被通过json反馈。
/// default: true
/// </summary>
public bool EnableSimApiException { get; set; } = true;
/// <summary>
/// 开启S3兼容的存储系统。
/// default: false
/// </summary>
2024-08-03 19:19:42 +08:00
public bool EnableSimApiStorage { get; set; }
2024-03-23 07:29:43 +08:00
/// <summary>
/// 开启ForwardHeaders,开启后可以透传负载均衡的Headers
/// default: true
/// </summary>
public bool EnableForwardHeaders { get; set; } = true;
/// <summary>
/// 将所有的url都格式化为小写字母
/// default: true
/// </summary>
public bool EnableLowerUrl { get; set; } = true;
/// <summary>
/// 启用格式化的 Console Logger
/// default: false
/// </summary>
2024-08-03 19:19:42 +08:00
public bool EnableLogger { get; set; }
2024-03-23 07:29:43 +08:00
/// <summary>
/// 是否启用Synapse
/// </summary>
2024-08-03 19:19:42 +08:00
public bool EnableSynapse { get; set; }
2024-03-23 07:29:43 +08:00
/// <summary>
/// Swagger文档相关配置,需要启用 EnableSimApiDoc
/// </summary>
public SimApiDocOptions SimApiDocOptions { get; set; } = new();
/// <summary>
/// S3兼容的存储系统配置,需要启用 EnableSimApiStorage
/// </summary>
public SimApiStorageOptions SimApiStorageOptions { get; set; } = new();
public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new();
2024-08-03 19:19:42 +08:00
public void ConfigureSimApiSynapse(Action<SimApiSynapseOptions>? options = null)
{
2024-03-23 07:29:43 +08:00
options?.Invoke(SimApiSynapseOptions);
}
2022-06-29 02:50:15 +08:00
2024-08-19 03:39:35 +08:00
public void ConfigureCoceSdk(Action<CoceAppSdkOption>? options = null)
2024-03-23 07:29:43 +08:00
{
2024-08-19 03:39:35 +08:00
options?.Invoke(CoceSdkOptions);
2024-03-23 07:29:43 +08:00
}
2022-06-29 02:50:15 +08:00
2024-08-03 19:19:42 +08:00
public void ConfigureSimApiDoc(Action<SimApiDocOptions>? options = null)
2024-03-23 07:29:43 +08:00
{
options?.Invoke(SimApiDocOptions);
}
2022-06-29 02:50:15 +08:00
2024-08-03 19:19:42 +08:00
public void ConfigureSimApiStorage(Action<SimApiStorageOptions>? options = null)
2024-03-23 07:29:43 +08:00
{
options?.Invoke(SimApiStorageOptions);
}
}