MCPcopy Create free account
hub / github.com/damienbod/AngularWebpackVisualStudio / Startup

Class Startup

src/AngularWebpackVisualStudio/Startup.cs:11–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace AngularWebpackVisualStudio
10{
11 public class Startup
12 {
13 public Startup(IConfiguration configuration)
14 {
15 Configuration = configuration;
16 }
17
18 public IConfiguration Configuration { get; }
19
20 public void ConfigureServices(IServiceCollection services)
21 {
22 services.AddCors(options =>
23 {
24 options.AddPolicy("AllowAllOrigins",
25 builder =>
26 {
27 builder
28 .AllowAnyOrigin()
29 .AllowAnyHeader()
30 .AllowAnyMethod();
31 });
32 });
33
34 services.AddSingleton<IThingsRepository, ThingsRepository>();
35 services.AddControllersWithViews();
36 }
37
38 public void Configure(IApplicationBuilder app)
39 {
40 app.UseCors("AllowAllOrigins");
41
42 var angularRoutes = new[] {
43 "/home",
44 "/about"
45 };
46
47 app.Use(async (context, next) =>
48 {
49 if (context.Request.Path.HasValue && null != angularRoutes.FirstOrDefault(
50 (ar) => context.Request.Path.Value.StartsWith(ar, StringComparison.OrdinalIgnoreCase)))
51 {
52 context.Request.Path = new PathString("/");
53 }
54
55 await next();
56 });
57
58 app.UseDefaultFiles();
59 app.UseStaticFiles();
60
61 app.UseRouting();
62
63 app.UseEndpoints(endpoints =>
64 {
65 endpoints.MapControllerRoute(
66 name: "default",
67 pattern: "{controller=Home}/{action=Index}/{id?}");
68 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected