Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Pull DI lookups out of lambda
  • Loading branch information
amcasey committed May 4, 2023
commit 904aec8907ceef3d691047859ec520a85db85ac0
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ private static ListenOptions UseHttps(this ListenOptions listenOptions, Lazy<Htt
listenOptions.IsTls = true;
listenOptions.HttpsOptions = lazyHttpsOptions;

var loggerFactory = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<ILoggerFactory>();
var metrics = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<KestrelMetrics>();

// NB: This lambda will only be invoked if either HTTP/1.* or HTTP/2 is being used
listenOptions.Use(next =>
{
// Evaluate the HttpsConnectionAdapterOptions, now that the configuration, if any, has been loaded
var httpsOptions = lazyHttpsOptions.Value;
var loggerFactory = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<ILoggerFactory>();
var metrics = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<KestrelMetrics>();
var middleware = new HttpsConnectionMiddleware(next, httpsOptions, listenOptions.Protocols, loggerFactory, metrics);
return middleware.OnConnectionAsync;
});
Expand Down