Browse Source

moved Kestrel configuration to appsettings

ipaddr
Galip Tolga Erdem 5 years ago
parent
commit
ccb2e9548e
  1. 44
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs
  2. 12
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json
  3. 7
      shared/EShopOnAbp.Shared.Hosting.AspNetCore/ApplicationBuilderHelper.cs

44
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/Program.cs

@ -2,10 +2,6 @@
using System.Threading.Tasks;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
namespace EShopOnAbp.CatalogService;
@ -22,29 +18,7 @@ public class Program
{
Log.Information($"Starting {assemblyName}.");
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.ConfigureEndpointDefaults(listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
});
serverOptions.ListenLocalhost(44354, opts =>
{
opts.UseHttps();
opts.Protocols = HttpProtocols.Http1AndHttp2;
});
// Grpc port
serverOptions.ListenLocalhost(81, opts => { opts.Protocols = HttpProtocols.Http2; });
});
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
await builder.AddApplicationAsync<CatalogServiceHttpApiHostModule>();
var app = builder.Build();
var app = await ApplicationBuilderHelper.BuildApplicationAsync<CatalogServiceHttpApiHostModule>(args);
await app.InitializeApplicationAsync();
await app.RunAsync();
@ -60,20 +34,4 @@ public class Program
Log.CloseAndFlush();
}
}
// static (int httpPort, int grpcPort) GetDefinedPorts(IConfiguration config)
// {
// var grpcPort = config.GetValue("GRPC_PORT", 81);
// var port = config.GetValue("PORT", 80);
// return (port, grpcPort);
// }
//
// static IConfiguration GetConfiguration()
// {
// return new ConfigurationBuilder()
// .SetBasePath(Directory.GetCurrentDirectory())
// .AddJsonFile("appsettings.json")
// .AddEnvironmentVariables()
// .Build();
// }
}

12
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json

@ -40,5 +40,17 @@
},
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "https://localhost:44354",
"Protocols": "Http1AndHttp2"
},
"gRPC": {
"Url": "http://localhost:81",
"Protocols": "Http2"
}
}
}
}

7
shared/EShopOnAbp.Shared.Hosting.AspNetCore/ApplicationBuilderHelper.cs

@ -15,13 +15,6 @@ public static class ApplicationBuilderHelper
where TStartupModule : IAbpModule
{
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.ConfigureEndpointDefaults(listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
});
});
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()

Loading…
Cancel
Save