推薦一個熱拔插API——TigerWebApi

TigerWebApi 是什麼?

TigerWebApi 是一個熱插拔的API,實現了項目不停止的情況下對項目API進行更新。

https://github.com/DeyiXu/TigerWebApi​github.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 在類當中添加MethodAttribute。繼承BaseMetchod類或者實現ITigerMethod方法

使用方法 http://ASP.NET Core

  1. 引用�Tiger.WebApi.Core
  2. Startup > ConfigureServices 方法中添加
services.SettingsTigerWebApi();
  1. Startup > Configure
app.Map("/info", ApiHandler.Info);
app.Map("/rest", ApiHandler.Map);
  1. 啓動項目
  2. 如?(例子)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);
}

請求協議

 

 

 

 

開源協議

MIT​github.com

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章