推荐一个热拔插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

 

 

 

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