项目作者: NeilQ

项目描述 :
A http proxy middleware for asp.net core app
高级语言: C#
项目地址: git://github.com/NeilQ/Netcool.HttpProxy.git
创建时间: 2020-02-08T09:59:58Z
项目社区:https://github.com/NeilQ/Netcool.HttpProxy

开源协议:Apache License 2.0

下载


Netcool.HttpProxy [Archived]

This GitHub project has been archived. Ongoing development on this prototype can be found in https://github.com/NeilQ/Netcool.Api/tree/master/src/extensions/Netcool.HttpProxy.

A http proxy for asp.net core app base on netstandard2.1.

Most of the codes comes from aspnet/AspLabs

Usage

  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. services.AddProxy(options =>
  4. {
  5. options.MessageHandler = new HttpClientHandler
  6. {
  7. AllowAutoRedirect = false
  8. };
  9. options.PrepareRequest = (originalRequest, message) =>
  10. {
  11. message.Headers.Add("X-Forwarded-Host", originalRequest.Host.Host);
  12. return Task.FromResult(0);
  13. };
  14. });
  15. }
  16. public void Configure(IApplicationBuilder app)
  17. {
  18. app.Map("/api", builder => { builder.RunProxy(new Uri("http://api.domain.com")); });
  19. }