优点:简化api调用过程,WebApiClient.AOT.dll中的IHttpApi接口

缺点:只适用于内部服务之间的调用(没有验证过程)

1.继承IHttpAPi接口

 public interface IService: IHttpApi
{
[HttpGet("api/getvalue/{id}")]
Task<ValueModel> GetValue([PathQuery]Guid id); [HttpGet("api/getallvalue")]
Task<ValueModel[]> GetValues();
}

2.在startup中注入

services.AddSingleton(serviceProvider => HttpApiClient.Create<IService>(serviceProvider.GetRequiredService<ApiConfig>()));

3.在ApiConfig配置api地址

 public class ApiConfig : HttpApiConfig
{
public ApiConfig(IConfiguration configuration, ILoggerFactory loggingFactory)
{
var httpHost = configuration["apiurl"];//apiurl在配置文件中
HttpHost = new Uri(httpHost);
}
}

然后,就可以使用IService.GetValue(id)调用api/getvalue/{id}

最新文章

  1. October 26th Week 44th Wednesday 2016
  2. Struts2 自定义MVC框架
  3. oracle 11g ORA-12541: TNS: 无监听程序 (DBD ERROR: OCIServerAttach)
  4. LeetCode Find Peak Element
  5. HashPasswordForStoringInConfigFile 已过时
  6. H5离线缓存机制-manifest
  7. contos 安装jdk1.8
  8. 【5】python核心编程 第八章-条件和循环
  9. uva140
  10. [POJ2823]Sliding Window 滑动窗口(单调队列)
  11. 使用re开发python计算器
  12. Android开发 ViewConfiguration 用法
  13. Netty学习记录
  14. ll(ls -l) 列属性
  15. 【转】WPF自定义控件与样式(3)-TextBox &amp; RichTextBox &amp; PasswordBox样式、水印、Label标签、功能扩展
  16. Django后端项目----restful framework 认证源码流程
  17. sprint初步计划(第一天)
  18. iOS开发网络篇—Socket编程
  19. Layui 好用的弹出框
  20. jq实现 元素显示后 点击页面的任何位置除元素本身外 隐藏元素

热门文章

  1. python 中str字符串 和list列表基本操作总结
  2. div 旋转
  3. redux小结
  4. OpenLayers介绍和第一个例子(转载)
  5. QT5.3 杂记
  6. javascript 匿名函数及闭包----转载
  7. SQL点点滴滴_UPDATE小计
  8. Skip List &amp; Bloom Filter
  9. 放弃setInterval-说说定时器
  10. ssh_exchange_identification: Connection closed by remote host