// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Diagnostics { /// /// This middleware provides a default web page for new applications. /// public class WelcomePageMiddleware { private readonly RequestDelegate _next; private readonly WelcomePageOptions _options; /// /// Creates a default web page for new applications. /// /// /// public WelcomePageMiddleware([NotNull] RequestDelegate next, [NotNull] WelcomePageOptions options) { _next = next; _options = options; } /// /// Process an individual request. /// /// /// public Task Invoke(HttpContext context) { HttpRequest request = context.Request; if (!_options.Path.HasValue || _options.Path == request.Path) { // Dynamically generated for LOC. var welcomePage = new WelcomePage(); return welcomePage.ExecuteAsync(context); } return _next(context); } } }