-
Notifications
You must be signed in to change notification settings - Fork 10.2k
/
Copy pathSpaOptions.cs
78 lines (69 loc) · 2.81 KB
/
SpaOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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
{
/// <summary>
/// Describes options for hosting a Single Page Application (SPA).
/// </summary>
public class SpaOptions
{
private PathString _defaultPage = "/index.html";
/// <summary>
/// Constructs a new instance of <see cref="SpaOptions"/>.
/// </summary>
public SpaOptions()
{
}
/// <summary>
/// Constructs a new instance of <see cref="SpaOptions"/>.
/// </summary>
/// <param name="copyFromOptions">An instance of <see cref="SpaOptions"/> from which values should be copied.</param>
internal SpaOptions(SpaOptions copyFromOptions)
{
_defaultPage = copyFromOptions.DefaultPage;
DefaultPageStaticFileOptions = copyFromOptions.DefaultPageStaticFileOptions;
SourcePath = copyFromOptions.SourcePath;
}
/// <summary>
/// Gets or sets the URL of the default page that hosts your SPA user interface.
/// The default value is <c>"/index.html"</c>.
/// </summary>
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;
}
}
/// <summary>
/// Gets or sets the <see cref="StaticFileOptions"/> that supplies content
/// for serving the SPA's default page.
///
/// If not set, a default file provider will read files from the
/// <see cref="IHostingEnvironment.WebRootPath"/>, which by default is
/// the <c>wwwroot</c> directory.
/// </summary>
public StaticFileOptions DefaultPageStaticFileOptions { get; set; }
/// <summary>
/// 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.
/// </summary>
public string SourcePath { get; set; }
/// <summary>
/// Gets or sets the maximum duration that a request will wait for the SPA
/// to become ready to serve to the client.
/// </summary>
public TimeSpan StartupTimeout { get; set; } = TimeSpan.FromSeconds(120);
}
}