forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomOcelotSetup.cs
More file actions
33 lines (28 loc) · 1005 Bytes
/
CustomOcelotSetup.cs
File metadata and controls
33 lines (28 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Blog.Core.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Nacos;
using Ocelot.Provider.Polly;
using System;
using System.Threading.Tasks;
namespace Blog.Core.Gateway.Extensions
{
public static class CustomOcelotSetup
{
public static void AddCustomOcelotSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
var basePath = AppContext.BaseDirectory;
services.AddAuthentication_JWTSetup();
services.AddOcelot().AddDelegatingHandler<CustomResultHandler>().AddNacosDiscovery().AddPolly();
//.AddConsul().AddPolly();
}
public static async Task<IApplicationBuilder> UseCustomOcelotMildd(this IApplicationBuilder app)
{
await app.UseOcelot();
return app;
}
}
}