public void Configure( IApplicationBuilder app, IWebHostEnvironment env, WebAppAndElmAppConfig webAppAndElmAppConfig, Func <DateTimeOffset> getDateTimeOffset, IHostApplicationLifetime appLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var state = new PublicAppState(webAppAndElmAppConfig: webAppAndElmAppConfig, getDateTimeOffset: getDateTimeOffset); appLifetime.ApplicationStopping.Register(() => { state.applicationStoppingCancellationTokenSource.Cancel(); _logger?.LogInformation("Public app noticed ApplicationStopping."); }); if (webAppAndElmAppConfig.WebAppConfiguration?.letsEncryptOptions != null) { app.UseFluffySpoonLetsEncryptChallengeApprovalMiddleware(); } state.ProcessEventTimeHasArrived(); app .Use(async(context, next) => await Asp.MiddlewareFromWebAppConfig(webAppAndElmAppConfig.WebAppConfiguration, context, next)) .Run(state.Run); }