Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Startup.fs « aspnetcoremvc11 « Samples « MonoDevelop.FSharp.Tests « fsharpbinding « external « main - github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 119fe3f2bbd4815258da454b83e228cb76adf7e9 (plain)
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
namespace aspnetcoremvc11

open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging

type Startup private () = 
    
    new(env : IHostingEnvironment) as this = 
        Startup()
        then 
            let builder = 
                ConfigurationBuilder().SetBasePath(env.ContentRootPath)
                    .AddJsonFile("appsettings.json", optional = false, reloadOnChange = true)
                    .AddJsonFile((sprintf "appsettings.%s.json" (env.EnvironmentName)), optional = true)
                    .AddEnvironmentVariables()
            this.Configuration <- builder.Build()
    
    // This method gets called by the runtime. Use this method to add services to the container.
    member this.ConfigureServices(services : IServiceCollection) = 
        // Add framework services.
        services.AddMvc() |> ignore
    
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    member this.Configure(app : IApplicationBuilder, env : IHostingEnvironment, loggerFactory : ILoggerFactory) = 
        loggerFactory.AddConsole(this.Configuration.GetSection("Logging")) |> ignore
        loggerFactory.AddDebug() |> ignore
        if (env.IsDevelopment()) then 
            app.UseDeveloperExceptionPage() |> ignore
            app.UseBrowserLink() |> ignore
        else app.UseExceptionHandler("/Home/Error") |> ignore
        app.UseStaticFiles() |> ignore
        app.UseMvc
            (fun routes -> 
            routes.MapRoute(name = "default", template = "{controller=Home}/{action=Index}/{id?}") |> ignore) |> ignore
    
    member val Configuration : IConfigurationRoot = null with get, set