2021-06-03 13:43:46 +08:00
|
|
|
using System;
|
2026-08-10 22:07:38 +08:00
|
|
|
using System.Collections.Generic;
|
2021-06-03 13:43:46 +08:00
|
|
|
|
2024-04-16 06:57:56 +08:00
|
|
|
namespace SimApi.Configurations;
|
2024-03-23 07:29:43 +08:00
|
|
|
|
|
|
|
|
public class SimApiOptions
|
2021-06-03 13:43:46 +08:00
|
|
|
{
|
2026-08-10 22:07:38 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Redis配置
|
|
|
|
|
/// </summary>
|
2025-01-16 22:05:59 +08:00
|
|
|
public string? RedisConfiguration { get; set; }
|
|
|
|
|
|
2026-08-10 22:07:38 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 原样返回给前端的配置信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Dictionary<string, object>? WebConfig { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// WebConfig返回是否包含版本信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool WebConfigIncludeVersion { get; set; } = true;
|
|
|
|
|
|
2025-01-16 22:05:59 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否启用后台任务系统 *基于Hangfire
|
|
|
|
|
/// </summary>
|
2025-01-17 01:30:13 +08:00
|
|
|
public bool EnableJob { get; set; }
|
2024-03-23 07:29:43 +08:00
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
2026-08-07 03:45:19 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 启用Cache功能
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableSimApiCache { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
|
2026-05-03 19:34:47 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 启用SimApi网关授权, 基于上层网关透传的身份令牌验证
|
|
|
|
|
/// </summary>
|
2026-05-12 09:39:23 +08:00
|
|
|
public bool EnableSimApiAuthGate { get; set; }
|
2024-08-19 03:39:35 +08:00
|
|
|
|
2025-01-17 01:30:13 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 开启S3兼容的存储系统。
|
|
|
|
|
/// default: false
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableSimApiStorage { get; set; }
|
2024-08-19 03:39:35 +08:00
|
|
|
|
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
|
|
|
|
2025-01-17 01:30:13 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否启用Synapse
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableSynapse { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启用全部Cors,对于开发前后分离的时候很有用。
|
|
|
|
|
/// default: true
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableCors { get; set; } = true;
|
|
|
|
|
|
2024-03-23 07:29:43 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 启用异常拦截,启用后,所有的异常将被通过json反馈。
|
|
|
|
|
/// default: true
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableSimApiException { get; set; } = true;
|
2025-01-16 22:05:59 +08:00
|
|
|
|
2024-12-23 20:34:38 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 启用返回结果拦截
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableSimApiResponseFilter { get; set; } = true;
|
2024-03-23 07:29:43 +08:00
|
|
|
|
2026-07-11 16:15:03 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 启用请求日志中间件
|
|
|
|
|
/// default: false
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableRequestLog { 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>
|
2025-01-17 01:30:13 +08:00
|
|
|
public bool EnableLogger { get; set; } = true;
|
2024-03-23 07:29:43 +08:00
|
|
|
|
2026-05-12 11:48:37 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 是否启用SimApiHttpClient
|
|
|
|
|
/// </summary>
|
2026-05-10 20:24:08 +08:00
|
|
|
public bool EnableSimApiHttpClient { get; set; } = false;
|
|
|
|
|
|
2025-01-16 22:05:59 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 配置Job
|
|
|
|
|
/// </summary>
|
|
|
|
|
public SimApiJobOptions SimApiJobOptions { get; set; } = new();
|
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();
|
|
|
|
|
|
2026-05-20 10:53:41 +08:00
|
|
|
public SimApiAuthCenterOptions SimApiAuthCenterOptions { get; set; } = new();
|
2026-05-03 19:34:47 +08:00
|
|
|
|
2026-05-10 20:24:08 +08:00
|
|
|
public SimApiHttpClientOptions SimApiHttpClientOptions { get; set; } = new();
|
|
|
|
|
|
2026-05-10 20:33:25 +08:00
|
|
|
public SimApiExceptionOptions SimApiExceptionOptions { get; set; } = new();
|
|
|
|
|
|
2026-05-12 11:48:37 +08:00
|
|
|
public SimApiRouteOptions SimApiRouteOptions { get; set; } = new();
|
|
|
|
|
|
2026-07-11 16:15:03 +08:00
|
|
|
public SimApiRequestLogOptions SimApiRequestLogOptions { get; set; } = new();
|
|
|
|
|
|
2026-05-12 11:48:37 +08:00
|
|
|
public void ConfigureSimApiRoute(Action<SimApiRouteOptions>? options = null)
|
|
|
|
|
{
|
|
|
|
|
options?.Invoke(SimApiRouteOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-10 20:33:25 +08:00
|
|
|
public void ConfigureSimApiException(Action<SimApiExceptionOptions>? options = null)
|
|
|
|
|
{
|
|
|
|
|
options?.Invoke(SimApiExceptionOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-10 20:24:08 +08:00
|
|
|
public void ConfigureSimApiHttpClient(Action<SimApiHttpClientOptions>? options = null)
|
|
|
|
|
{
|
|
|
|
|
options?.Invoke(SimApiHttpClientOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-03 19:19:42 +08:00
|
|
|
public void ConfigureSimApiSynapse(Action<SimApiSynapseOptions>? options = null)
|
2021-06-03 13:43:46 +08:00
|
|
|
{
|
2024-03-23 07:29:43 +08:00
|
|
|
options?.Invoke(SimApiSynapseOptions);
|
|
|
|
|
}
|
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);
|
2021-06-03 13:43:46 +08:00
|
|
|
}
|
2025-01-16 22:05:59 +08:00
|
|
|
|
|
|
|
|
public void ConfigureSimApiJob(Action<SimApiJobOptions>? options = null)
|
|
|
|
|
{
|
|
|
|
|
options?.Invoke(SimApiJobOptions);
|
|
|
|
|
}
|
2026-05-03 19:34:47 +08:00
|
|
|
|
2026-05-20 10:53:41 +08:00
|
|
|
public void ConfigureSimApiAuthCenter(Action<SimApiAuthCenterOptions>? options = null)
|
2026-05-03 19:34:47 +08:00
|
|
|
{
|
2026-05-20 10:53:41 +08:00
|
|
|
options?.Invoke(SimApiAuthCenterOptions);
|
2026-05-03 19:34:47 +08:00
|
|
|
}
|
2026-07-11 16:15:03 +08:00
|
|
|
|
|
|
|
|
public void ConfigureSimApiRequestLog(Action<SimApiRequestLogOptions>? options = null)
|
|
|
|
|
{
|
|
|
|
|
options?.Invoke(SimApiRequestLogOptions);
|
|
|
|
|
}
|
2021-06-03 13:43:46 +08:00
|
|
|
}
|