Add a proper Gateway service

This commit is contained in:
2025-09-23 22:56:06 +08:00
parent 4573d9395f
commit 3b3287db0b
11 changed files with 278 additions and 66 deletions

View File

@@ -12,22 +12,27 @@ public static class KestrelConfiguration
public static WebApplicationBuilder ConfigureAppKestrel(
this WebApplicationBuilder builder,
IConfiguration configuration,
long maxRequestBodySize = 50 * 1024 * 1024
long maxRequestBodySize = 50 * 1024 * 1024,
bool enableGrpc = true
)
{
builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = maxRequestBodySize;
// gRPC
var grpcPort = int.Parse(configuration.GetValue<string>("GRPC_PORT", "5001"));
options.ListenAnyIP(grpcPort, listenOptions =>
if (enableGrpc)
{
listenOptions.Protocols = HttpProtocols.Http2;
// gRPC
var grpcPort = int.Parse(configuration.GetValue<string>("GRPC_PORT", "5001"));
options.ListenAnyIP(grpcPort, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
var selfSignedCert = _CreateSelfSignedCertificate();
listenOptions.UseHttps(selfSignedCert);
});
}
var selfSignedCert = _CreateSelfSignedCertificate();
listenOptions.UseHttps(selfSignedCert);
});
var httpPorts = configuration.GetValue<string>("HTTP_PORTS", "6000")
.Split(',', StringSplitOptions.RemoveEmptyEntries)
@@ -68,4 +73,4 @@ public static class KestrelConfiguration
var pfxBytes = certificate.Export(X509ContentType.Pfx);
return X509CertificateLoader.LoadPkcs12(pfxBytes, password: null);
}
}
}