feat 网关继承微服务Swagger
This commit is contained in:
@ -1,9 +1,6 @@
|
||||
using KonSoft.InternalGateway;
|
||||
using KonSoft.InternalGateway.Extensions;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using Microsoft.AspNetCore.Rewrite;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using KonSoft.Shared.Hosting.Gateways;
|
||||
using Serilog;
|
||||
|
||||
var assemblyName = typeof(Program).Assembly.GetName().Name!;
|
||||
@ -11,6 +8,8 @@ SerilogConfigurationHelper.Configure(assemblyName);
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information($"Starting {assemblyName}.");
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration
|
||||
.AddAgileConfig(option =>
|
||||
@ -19,30 +18,13 @@ try
|
||||
});
|
||||
builder.Host
|
||||
.AddAppSettingsSecretsJson()
|
||||
.AddYarpJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
|
||||
builder.Services.AddAbpSwaggerGenWithOidc(builder.Configuration["AuthServer:Authority"]!, setupAction: options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "Gateway",
|
||||
Version = "v1"
|
||||
});
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
});
|
||||
|
||||
|
||||
builder.Services.AddReverseProxy()
|
||||
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
|
||||
builder.Services.AddControllers();
|
||||
await builder.AddApplicationAsync<InternalGatewayModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
app.UseSwaggerUIWithYarp();
|
||||
app.MapReverseProxy();
|
||||
app.MapGet("/heath", () => "Online");
|
||||
await app.RunAsync();
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user