diff --git a/Storage/Storage/LCCloud.cs b/Storage/Storage/LCCloud.cs index 01066c7..ed8fc2f 100644 --- a/Storage/Storage/LCCloud.cs +++ b/Storage/Storage/LCCloud.cs @@ -7,6 +7,15 @@ namespace LeanCloud.Storage { /// 云引擎 /// public static class LCCloud { + private const string PRODUCTION_KEY = "X-LC-Prod"; + + /// + /// 是否是生产环境,默认为 true + /// + public static bool IsProduction { + get; set; + } = true; + /// /// 调用云函数 /// @@ -16,8 +25,12 @@ namespace LeanCloud.Storage { public static async Task> Run(string name, Dictionary parameters = null) { string path = $"functions/{name}"; + Dictionary headers = new Dictionary { + { PRODUCTION_KEY, IsProduction ? 1 : 0 } + }; object encodeParams = LCEncoder.Encode(parameters); Dictionary response = await LCApplication.HttpClient.Post>(path, + headers: headers, data: encodeParams); return response; } @@ -30,8 +43,12 @@ namespace LeanCloud.Storage { /// 返回类型为 LCObject 容器类型 public static async Task RPC(string name, object parameters = null) { string path = $"call/{name}"; + Dictionary headers = new Dictionary { + { PRODUCTION_KEY, IsProduction ? 1 : 0 } + }; object encodeParams = LCEncoder.Encode(parameters); Dictionary response = await LCApplication.HttpClient.Post>(path, + headers: headers, data: encodeParams); return LCDecoder.Decode(response["result"]); }