forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartup.cs
More file actions
91 lines (69 loc) · 2.9 KB
/
Copy pathStartup.cs
File metadata and controls
91 lines (69 loc) · 2.9 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace LocalhostWebServer
{
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
public class Startup
{
public const string StaticFileRequestPath = "/TestKit";
public static string StaticFileRoot { get; set; }
public static string CertPath { get; set; }
public static string CertPassword { get; set; }
public static string OutCertFile { get; set; }
public static int Port { get; set; }
public static string LocalSourceJson { get; set; }
public static string TestDataPath { get; set; }
public static bool ExitBeforeRun { get; set; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
}
public IConfiguration Configuration { get; }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
//Add .yaml and .msix mappings
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".yml"] = "application/x-yaml";
provider.Mappings[".yaml"] = "application/x-yaml";
provider.Mappings[".msix"] = "application/msix";
provider.Mappings[".exe"] = "application/x-msdownload";
provider.Mappings[".msi"] = "application/msi";
provider.Mappings[".appx"] = "application/vns.ms-appx";
provider.Mappings[".appxbundle"] = "application/vns.ms-appx";
provider.Mappings[".mszyml"] = "application/x-ms-zip-yaml";
//Enable static file serving
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(StaticFileRoot),
RequestPath = StaticFileRequestPath,
ContentTypeProvider = provider,
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(StaticFileRoot),
RequestPath = StaticFileRequestPath
});
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});
}
}
}