Files
simapi-cj/src/configurations/SimApiOptions.cj
T

190 lines
5.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* Copyright (c) 2025 SimcuTeam. All rights reserved.
* 移植自 C# 项目 SimApiE:\simcu\simapi-net),遵循 MIT 许可证。
* 对齐 C# 的 Configurations/SimApiOptions.cs。
*/
package simcu::simapi.configurations
import std.collection.*
/**
* SimApi 全局配置:对应 C# 的 SimApi.Configurations.SimApiOptions。
*/
public class SimApiOptions {
/**
* Redis 配置;配置则使用 Redis,不配则自动使用 InMemory。
*/
public var redisConfiguration: String = ""
/**
* 原样返回给前端的配置信息。
*/
public var webConfig: HashMap<String, Any> = HashMap<String, Any>()
/**
* WebConfig 返回是否包含版本信息。
*/
public var webConfigIncludeVersion: Bool = true
/**
* 是否启用后台任务系统(占位,未实现)。
*/
public var enableJob: Bool = false
/**
* 启用 Token 认证。
*/
public var enableSimApiAuth: Bool = false
/**
* 启用缓存功能(默认 true)。
*/
public var enableSimApiCache: Bool = true
/**
* 启用网关授权(占位,未实现)。
*/
public var enableSimApiAuthGate: Bool = false
/**
* 开启 S3 兼容存储(占位,未实现)。
*/
public var enableSimApiStorage: Bool = false
/**
* 启用在线文档(占位,未实现)。
*/
public var enableSimApiDoc: Bool = false
/**
* 是否启用 Synapse(占位,未实现)。
*/
public var enableSynapse: Bool = false
/**
* 启用全部 CORS(默认 true)。
*/
public var enableCors: Bool = true
/**
* 启用异常拦截(默认 true)。
*/
public var enableSimApiException: Bool = true
/**
* 启用返回结果拦截(默认 true)。
*/
public var enableSimApiResponseFilter: Bool = true
/**
* 启用请求日志中间件。
*/
public var enableRequestLog: Bool = false
/**
* 开启 ForwardHeaders(默认 true)。
*/
public var enableForwardHeaders: Bool = true
/**
* 将 url 格式化为小写(默认 true)。
*/
public var enableLowerUrl: Bool = true
/**
* 启用格式化 Console Logger(默认 true)。
*/
public var enableLogger: Bool = true
/**
* 是否启用 SimApiHttpClient。
*/
public var enableSimApiHttpClient: Bool = false
public var simApiJobOptions = SimApiJobOptions()
public var simApiDocOptions = SimApiDocOptions()
public var simApiStorageOptions = SimApiStorageOptions()
public var simApiSynapseOptions = SimApiSynapseOptions()
public var simApiAuthCenterOptions = SimApiAuthCenterOptions()
public var simApiHttpClientOptions = SimApiHttpClientOptions()
public var simApiExceptionOptions = SimApiExceptionOptions()
public var simApiRouteOptions = SimApiRouteOptions()
public var simApiRequestLogOptions = SimApiRequestLogOptions()
// ===== .NET 风格配置回调(对齐 C# ConfigureSimApiXxx(opt => ...) =====
/**
* 配置路由选项。
* @param configure 路由配置回调。
*/
public func configureSimApiRoute(configure: (SimApiRouteOptions) -> Unit): Unit {
configure(simApiRouteOptions)
}
/**
* 配置异常处理选项。
* @param configure 异常配置回调。
*/
public func configureSimApiException(configure: (SimApiExceptionOptions) -> Unit): Unit {
configure(simApiExceptionOptions)
}
/**
* 配置 HTTP 客户端选项。
* @param configure 客户端配置回调。
*/
public func configureSimApiHttpClient(configure: (SimApiHttpClientOptions) -> Unit): Unit {
configure(simApiHttpClientOptions)
}
/**
* 配置文档选项(占位)。
* @param configure 文档配置回调。
*/
public func configureSimApiDoc(configure: (SimApiDocOptions) -> Unit): Unit {
configure(simApiDocOptions)
}
/**
* 配置存储选项(占位)。
* @param configure 存储配置回调。
*/
public func configureSimApiStorage(configure: (SimApiStorageOptions) -> Unit): Unit {
configure(simApiStorageOptions)
}
/**
* 配置任务调度选项(占位)。
* @param configure 任务配置回调。
*/
public func configureSimApiJob(configure: (SimApiJobOptions) -> Unit): Unit {
configure(simApiJobOptions)
}
/**
* 配置 Synapse 选项(占位)。
* @param configure Synapse 配置回调。
*/
public func configureSimApiSynapse(configure: (SimApiSynapseOptions) -> Unit): Unit {
configure(simApiSynapseOptions)
}
/**
* 配置请求日志选项(对齐 C# ConfigureSimApiRequestLog)。
* @param configure 请求日志配置回调。
*/
public func configureSimApiRequestLog(configure: (SimApiRequestLogOptions) -> Unit): Unit {
configure(simApiRequestLogOptions)
}
/**
* 配置认证中心选项(对齐 C# ConfigureSimApiAuthCenter)。
* @param configure 认证中心配置回调。
*/
public func configureSimApiAuthCenter(configure: (SimApiAuthCenterOptions) -> Unit): Unit {
configure(simApiAuthCenterOptions)
}
}