From 08ed1c240c08dd4a84713d90a10e23e2c5355a76 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 29 Jun 2020 11:28:21 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=94=AF=E6=8C=81=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=BA=91=E5=BC=95=E6=93=8E=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Storage/LCCloud.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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"]); }