云端部署方案优化浏览器直接打开
This commit is contained in:
+2
-1
@@ -34,7 +34,8 @@ var app = builder.Build();
|
|||||||
const string API_KEY = "UiHMqtaYLZzwBdcuS4RFmEGhgDO8N2eI";
|
const string API_KEY = "UiHMqtaYLZzwBdcuS4RFmEGhgDO8N2eI";
|
||||||
app.Use(async (context, next) =>
|
app.Use(async (context, next) =>
|
||||||
{
|
{
|
||||||
var key = context.Request.Headers["X-API-Key"].FirstOrDefault();
|
var key = context.Request.Headers["X-API-Key"].FirstOrDefault()
|
||||||
|
?? context.Request.Query["key"].FirstOrDefault();
|
||||||
if (key != API_KEY)
|
if (key != API_KEY)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = 401;
|
context.Response.StatusCode = 401;
|
||||||
|
|||||||
+39
-1
@@ -121,6 +121,23 @@ const string API_KEY = "你的随机密码";
|
|||||||
|
|
||||||
修改后重新编译,将新的 `Mt5Bridge.dll` 覆盖到目标主机。
|
修改后重新编译,将新的 `Mt5Bridge.dll` 覆盖到目标主机。
|
||||||
|
|
||||||
|
### 更新 DLL(服务运行时)
|
||||||
|
|
||||||
|
Bridge 作为后台服务运行时,文件被锁定无法直接覆盖。需要先停止再覆盖:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 阻止任务计划再次触发
|
||||||
|
Stop-ScheduledTask -TaskName "Mt5Bridge"
|
||||||
|
|
||||||
|
# 强制结束当前进程
|
||||||
|
taskkill /f /im dotnet.exe
|
||||||
|
|
||||||
|
# 现在可以覆盖 Mt5Bridge.dll 了
|
||||||
|
|
||||||
|
# 重新启动
|
||||||
|
Start-ScheduledTask -TaskName "Mt5Bridge"
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 四、端口映射(公网访问)
|
## 四、端口映射(公网访问)
|
||||||
@@ -180,12 +197,23 @@ Unregister-ScheduledTask -TaskName "Mt5Bridge" -Confirm:$false
|
|||||||
|
|
||||||
## 六、API 接口
|
## 六、API 接口
|
||||||
|
|
||||||
所有接口均需在 Header 中携带 API Key:
|
所有接口均需认证,支持两种方式:
|
||||||
|
|
||||||
|
**方式一:Header(推荐,适用于代码调用)**
|
||||||
```
|
```
|
||||||
X-API-Key: 你的密码
|
X-API-Key: 你的密码
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**方式二:URL 参数(适用于浏览器直接访问)**
|
||||||
|
```
|
||||||
|
?key=你的密码
|
||||||
|
```
|
||||||
|
|
||||||
|
示例:
|
||||||
|
```
|
||||||
|
http://IP:端口/health?key=你的密码
|
||||||
|
```
|
||||||
|
|
||||||
### 健康检查
|
### 健康检查
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -407,6 +435,16 @@ GET /history/deals?date_from={from}&date_to={to}&symbol={symbol}
|
|||||||
|
|
||||||
## 七、调用示例
|
## 七、调用示例
|
||||||
|
|
||||||
|
### 浏览器
|
||||||
|
|
||||||
|
直接在地址栏输入(带 `?key=` 参数):
|
||||||
|
|
||||||
|
```
|
||||||
|
http://IP:端口/health?key=你的密码
|
||||||
|
http://IP:端口/account?key=你的密码
|
||||||
|
http://IP:端口/symbols/XAUUSDc/tick?key=你的密码
|
||||||
|
```
|
||||||
|
|
||||||
### PowerShell
|
### PowerShell
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Mt5Bridge")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Mt5Bridge")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+279385d8fc1eedefb38ed10aca22ab8ff3708014")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ac1153c0914bcde0cebee04271eb48f6047e7c85")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Mt5Bridge")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Mt5Bridge")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Mt5Bridge")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Mt5Bridge")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4235236514da1df525d2d1220aead15991cbafc6db41ab379c545a99c2487020
|
3e51f6bbe9ff6ed0893f1911fc810b6691a001b8db244523b3de6ba0c5a11ab4
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user