TigerWebApi 是什麼?
TigerWebApi 是一個熱插拔的API,實現了項目不停止的情況下對項目API進行更新。
https://github.com/DeyiXu/TigerWebApigithub.com
環境
.NET Standard 2.0
ASP.NET Core 2.0
介紹
Tiger.WebApi.Core
是API處理的核心文件
Tiger.WebApi
是基於ASP.NET Core 2.0 引用和配置了Tiger.WebApi.Core
Tiger.WebApi.Client
是使用TigerWebApi的請求封裝
Tiger.Test
測試Api和Client使用到的,有使用TigerWebApiClient方法
Tiger.Account
處理和用戶相關的業務,引用 Tiger.WebApi.Core
在類當中添加Method
Attribute。繼承BaseMetchod
類或者實現ITigerMethod
方法
使用方法 http://ASP.NET Core
- 引用
�Tiger.WebApi.Core
- Startup > ConfigureServices 方法中添加
services.SettingsTigerWebApi();
- Startup > Configure
app.Map("/info", ApiHandler.Info);
app.Map("/rest", ApiHandler.Map);
- 啓動項目
- 如?(例子)
Tiger.Account
,發佈後\bin\Debug\netstandard2.0
對文件進行重命名Tiger.Account.dll|.pdb
>Item.dll|.pdb
(*.deps.json可以刪除)。
在WebApi下的Packages中新建任意文件夾可以以Tiger.Account
命名,複製剛剛修改好的Item等其他文件到Tiger.Account
文件夾中。
WebApi會自動加載,打開瀏覽器輸入http://localhost:5000/info
就能看到API信息。
Tiger.Test
項目中有封裝好的調用方式
IDictionary<string, string> dic = new Dictionary<string, string>
{
{ "v", "v1" },
{ "k2", "k2" },
{ "k3", "k3" },
{ "k4", "k4" }
};
using (ITigerWebApiClient client = new DefaultTigerWebApiClient("http://localhost:5000/rest", "10000", "qwerasdfzxcv"))
{
var content = client.Execute("tiger.service.account.getname", dic);
Console.WriteLine(content);
}
請求協議
開源協議