Skip to content

Commit

Permalink
Add kestral
Browse files Browse the repository at this point in the history
  • Loading branch information
Aron Heesakkers committed May 18, 2021
1 parent 52c7a8d commit 74a8853
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
32 changes: 28 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

Expand All @@ -18,10 +20,32 @@ public static void Main(string[] args)

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>

.ConfigureServices((context, services) =>
{
services.Configure<KestrelServerOptions>(
context.Configuration.GetSection("Kestrel"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions =>
{
webBuilder.UseStartup<Startup>()
.UseUrls("http://*:8123");
});
serverOptions.Limits.MaxConcurrentConnections = 100;
serverOptions.Limits.MaxConcurrentUpgradedConnections = 100;
serverOptions.Limits.MaxRequestBodySize = 10 * 1024;
serverOptions.Limits.MinRequestBodyDataRate =
new MinDataRate(bytesPerSecond: 100,
gracePeriod: TimeSpan.FromSeconds(10));
serverOptions.Limits.MinResponseDataRate =
new MinDataRate(bytesPerSecond: 100,
gracePeriod: TimeSpan.FromSeconds(10));
serverOptions.Limits.KeepAliveTimeout =
TimeSpan.FromDays(30);
serverOptions.Limits.RequestHeadersTimeout =
TimeSpan.FromDays(30);
})
.UseStartup<Startup>()
.UseUrls("http://*:8123");
});
}
}
4 changes: 4 additions & 0 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand All @@ -29,6 +30,9 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<KestrelServerOptions>(
Configuration.GetSection("Kestrel"));

Constants.PackageApiUrl = Configuration.GetValue<string>("PackageApiUrl");
Constants.LocationApiUrl = Configuration.GetValue<string>("LocationApiUrl");
Constants.PersonApiUrl = Configuration.GetValue<string>("PersonApiUrl");
Expand Down

0 comments on commit 74a8853

Please sign in to comment.