-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.fs
48 lines (37 loc) · 1.6 KB
/
Startup.fs
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
namespace ReactFS
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Mvc
open Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
type Startup () =
new (configuration: IConfiguration) as this =
Startup() then
this.Configuration <- configuration
member this.ConfigureServices(services: IServiceCollection) =
// Add framework services.
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) |> ignore
services.AddSpaStaticFiles(fun configuration ->
configuration.RootPath <- "ClientApp/build"
) |> ignore
member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) =
if (env.IsDevelopment()) then
app.UseDeveloperExceptionPage() |> ignore
else
app.UseHsts() |> ignore
app.UseStaticFiles() |> ignore
app.UseSpaStaticFiles() |> ignore
app.UseMvc(fun routes ->
routes.MapRoute(
name = "default",
template = "{controller=Home}/{action=Index}/{id?}") |> ignore
) |> ignore
app.UseSpa(fun spa ->
spa.Options.SourcePath <- "ClientApp"
if (env.IsDevelopment()) then
spa.UseReactDevelopmentServer("start") |> ignore
else
None |> ignore
) |> ignore
member val Configuration : IConfiguration = null with get, set