AS.NET Core AppゲートウェイOcellotの使用初探
概要
Ocellotは利用に向けて、NETがマイクロサービスを実行する/サービスに向けるアーキテクチャの人員に対して、これらの体系構造はシステムの中で統一的な入口点を持つ必要がある。特に私はIdentityServer参照とベアラトークンと簡単に統合したいです。Ocellotは特定の順序で並べられた一連の中間部品です。Ocentは、要求ビルダのミドルウェアに到達するまで、HttpRequestオブジェクトをその構成によって指定された状態で動作させ、中間部品において下流サービスに対する要求を行うためのHttpRequest Messageオブジェクトを作成する。要請した中間部品はOcellot配管の中の最後のものです。これは次の中間部品を呼び出しません。中間ウェアの一つがHttpResonseオブジェクトにマッピングされ、クライアントに返されます。基本的に、他の多くの機能を持っています。
コードの実装
1、新規アプリクライアント1
2、新規アプリの作成 ゲートウェイtest
3、nugtインストールOcell ot
4、ProgramファイルにConfigrepConfigrationを追加する
コードアドレス
https://gitee.com/conanOpenSource_admin/Example/comit/b 3 b 5 a 6 b 15 a 060 b 46 c 5 ecd 2 ea 31 f 0 d 36791 cda 18 c
以上はASP.NET Core AppゲートウェイOcellotの使用初心者の詳細です。ASP.NET Core AppゲートウェイOcentに関する資料は他の関連記事に注目してください。
Ocellotは利用に向けて、NETがマイクロサービスを実行する/サービスに向けるアーキテクチャの人員に対して、これらの体系構造はシステムの中で統一的な入口点を持つ必要がある。特に私はIdentityServer参照とベアラトークンと簡単に統合したいです。Ocellotは特定の順序で並べられた一連の中間部品です。Ocentは、要求ビルダのミドルウェアに到達するまで、HttpRequestオブジェクトをその構成によって指定された状態で動作させ、中間部品において下流サービスに対する要求を行うためのHttpRequest Messageオブジェクトを作成する。要請した中間部品はOcellot配管の中の最後のものです。これは次の中間部品を呼び出しません。中間ウェアの一つがHttpResonseオブジェクトにマッピングされ、クライアントに返されます。基本的に、他の多くの機能を持っています。
コードの実装
1、新規アプリクライアント1
2、新規アプリの作成 ゲートウェイtest
3、nugtインストールOcell ot
4、ProgramファイルにConfigrepConfigrationを追加する
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(conf =>
{
conf.AddJsonFile("ocelot.json", false, true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
5、Startupファイルの配置
services.AddOcelot(Configuration);
app.UseOcelot().Wait();
6、ゲートウェイプロジェクトにファイルのocelot.jsonを追加する
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/WeatherForecast/GetList",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/GetList",
"UpstreamHttpMethod": [ "Get" ]
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/{everything}",
"UpstreamHttpMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/WeatherForecast/GetModel?id={s1}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/GetModel?id={s1}",
"UpstreamHttpMethod": [ "Get" ]
}
]
}
7、2つのプロジェクトの運行、テストコードアドレス
https://gitee.com/conanOpenSource_admin/Example/comit/b 3 b 5 a 6 b 15 a 060 b 46 c 5 ecd 2 ea 31 f 0 d 36791 cda 18 c
以上はASP.NET Core AppゲートウェイOcellotの使用初心者の詳細です。ASP.NET Core AppゲートウェイOcentに関する資料は他の関連記事に注目してください。