namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// /// 请求/响应转换规则(值对象) /// 以 JSON 列存储在数据库中 /// public class GwTransform { /// /// 转换规则键值对 /// 例如: {"RequestHeader": "X-Custom-Header", "Set": "value"} /// public Dictionary Rules { get; set; } = new(); } /// /// 常用转换规则工厂 /// public static class GwTransforms { /// /// 设置请求头 /// public static GwTransform SetRequestHeader(string headerName, string value) => new() { Rules = new Dictionary { { "RequestHeader", headerName }, { "Set", value } }}; /// /// 添加请求头 /// public static GwTransform AppendRequestHeader(string headerName, string value) => new() { Rules = new Dictionary { { "RequestHeader", headerName }, { "Append", value } }}; /// /// 设置响应头 /// public static GwTransform SetResponseHeader(string headerName, string value) => new() { Rules = new Dictionary { { "ResponseHeader", headerName }, { "Set", value } }}; /// /// 移除路径前缀 /// public static GwTransform PathRemovePrefix(string prefix) => new() { Rules = new Dictionary { { "PathRemovePrefix", prefix } }}; /// /// 设置路径前缀 /// public static GwTransform PathSetPrefix(string prefix) => new() { Rules = new Dictionary { { "PathPrefix", prefix } }}; /// /// 使用原始 Host 头 /// public static GwTransform RequestHeaderOriginalHost() => new() { Rules = new Dictionary { { "RequestHeaderOriginalHost", "true" } }}; }