58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| 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 Serilog;
 | |
| 
 | |
| var assemblyName = typeof(Program).Assembly.GetName().Name!;
 | |
| SerilogConfigurationHelper.Configure(assemblyName);
 | |
| 
 | |
| try
 | |
| {
 | |
|     var builder = WebApplication.CreateBuilder(args);
 | |
|     builder.Configuration
 | |
|         .AddAgileConfig(option =>
 | |
|         {
 | |
|             option.ENV = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
 | |
|         });
 | |
|     builder.Host
 | |
|         .AddAppSettingsSecretsJson()
 | |
|         .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;
 | |
| }
 | |
| catch (Exception ex)
 | |
| {
 | |
|     Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
 | |
|     return 1;
 | |
| }
 | |
| finally
 | |
| {
 | |
|     await Log.CloseAndFlushAsync();
 | |
| } | 
