提交.Net6版本
This commit is contained in:
80
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs
Normal file
80
Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
using Ocelot.Provider.Consul;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Ocelot.Cache.CacheManager;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
using Ocelot.Provider.Polly;
|
||||
|
||||
namespace Yi.Framework.OcelotGateway
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddControllers();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddCorsService();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddOcelot().AddConsul().AddCacheManager(x =>{x.WithDictionaryHandle();}).AddPolly();
|
||||
|
||||
#region
|
||||
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddSwaggerService<Program>("Yi.Framework.OcelotGateway");
|
||||
#region
|
||||
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
services.AddJwtService();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
#region
|
||||
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseSwaggerService(new SwaggerModel("api/api/swagger/v1/swagger.json","API<50><49><EFBFBD><EFBFBD>"), new SwaggerModel("api/item/swagger/v1/swagger.json", "<22><>̬ҳ<CCAC><D2B3><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
#region
|
||||
//<2F><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseOcelot();
|
||||
|
||||
#region
|
||||
//<2F><>Ȩע<C8A8><D7A2>
|
||||
#endregion
|
||||
app.UseAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user