重构: 源码文件蛇形命名, 接口去I头(BindRequestContext/SimApiAuthChecker), 清理C#相关说明, serialization依赖路径改 serialization-cj
This commit is contained in:
1 parent
829f009229
commit
30e5f165f2
56 files changed
+319
-332
No files matched your search
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2025 SimcuTeam. All rights reserved.
|
||||
* 遵循 MIT 许可证。
|
||||
*/
|
||||
|
||||
package simcu::simapi.configurations
|
||||
|
||||
import std.collection.*
|
||||
|
||||
/**
|
||||
* SimApi 全局配置。
|
||||
*/
|
||||
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()
|
||||
|
||||
|
||||
// ===== 配置回调 =====
|
||||
|
||||
/**
|
||||
* 配置路由选项。
|
||||
* @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)
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置请求日志选项。
|
||||
* @param configure 请求日志配置回调。
|
||||
*/
|
||||
public func configureSimApiRequestLog(configure: (SimApiRequestLogOptions) -> Unit): Unit {
|
||||
configure(simApiRequestLogOptions)
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置认证中心选项。
|
||||
* @param configure 认证中心配置回调。
|
||||
*/
|
||||
public func configureSimApiAuthCenter(configure: (SimApiAuthCenterOptions) -> Unit): Unit {
|
||||
configure(simApiAuthCenterOptions)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user