// 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 Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.FileProviders; using System; namespace Microsoft.AspNetCore.SpaServices { /// /// Describes options for hosting a Single Page Application (SPA). /// public class SpaOptions { private PathString _defaultPage = "/index.html"; /// /// Constructs a new instance of . /// public SpaOptions() { } /// /// Constructs a new instance of . /// /// An instance of from which values should be copied. internal SpaOptions(SpaOptions copyFromOptions) { _defaultPage = copyFromOptions.DefaultPage; DefaultPageStaticFileOptions = copyFromOptions.DefaultPageStaticFileOptions; SourcePath = copyFromOptions.SourcePath; } /// /// Gets or sets the URL of the default page that hosts your SPA user interface. /// The default value is "/index.html". /// public PathString DefaultPage { get => _defaultPage; set { if (string.IsNullOrEmpty(value.Value)) { throw new ArgumentException($"The value for {nameof(DefaultPage)} cannot be null or empty."); } _defaultPage = value; } } /// /// Gets or sets the that supplies content /// for serving the SPA's default page. /// /// If not set, a default file provider will read files from the /// , which by default is /// the wwwroot directory. /// public StaticFileOptions DefaultPageStaticFileOptions { get; set; } /// /// Gets or sets the path, relative to the application working directory, /// of the directory that contains the SPA source files during /// development. The directory may not exist in published applications. /// public string SourcePath { get; set; } /// /// Gets or sets the maximum duration that a request will wait for the SPA /// to become ready to serve to the client. /// public TimeSpan StartupTimeout { get; set; } = TimeSpan.FromSeconds(50); } }