feat 网关继承微服务Swagger

This commit is contained in:
2025-11-01 23:30:58 +08:00
parent ccb12389ee
commit 3cc7d2b85d
30 changed files with 1385 additions and 68 deletions

View File

@ -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;