Skip to content

Commit

Permalink
Use minimal APIs for F# project templates (dotnet#35833)
Browse files Browse the repository at this point in the history
  • Loading branch information
vzarytovskii authored Sep 17, 2021
1 parent a94189e commit ba02425
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<Compile Include="Models/ErrorViewModel.fs" />
<Compile Include="Controllers/HomeController.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<Compile Include="WeatherForecast.fs" />
<Compile Include="Controllers/WeatherForecastController.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
namespace Company.WebApplication1

#nowarn "20"

open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
#if !NoHttps
open Microsoft.AspNetCore.HttpsPolicy
#endif
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging

module Program =
let exitCode = 0

let CreateHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(fun webBuilder ->
webBuilder.UseStartup<Startup>() |> ignore
)

[<EntryPoint>]
let main args =
CreateHostBuilder(args).Build().Run()
let builder = WebApplication.CreateBuilder(args)

builder
.Services
.AddControllersWithViews()
.AddRazorRuntimeCompilation()

builder.Services.AddRazorPages()

let app = builder.Build()

if not (builder.Environment.IsDevelopment()) then
app.UseExceptionHandler("/Home/Error")
#if !NoHttps
app.UseHsts() |> ignore // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.

app.UseHttpsRedirection()
#endif

app.UseStaticFiles()
app.UseRouting()
app.UseAuthorization()

app.MapControllerRoute(name = "default", pattern = "{controller=Home}/{action=Index}/{id?}")

app.MapRazorPages()

app.Run()

exitCode

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
namespace Company.WebApplication1

#nowarn "20"
open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
#if !NoHttps
open Microsoft.AspNetCore.HttpsPolicy
#endif
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging

module Program =
let exitCode = 0

let CreateHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(fun webBuilder ->
webBuilder.UseStartup<Startup>() |> ignore
)

[<EntryPoint>]
let main args =
CreateHostBuilder(args).Build().Run()

let builder = WebApplication.CreateBuilder(args)

builder.Services.AddControllers()

let app = builder.Build()

#if !NoHttps
app.UseHttpsRedirection()
#endif

app.UseAuthorization()
app.MapControllers()

app.Run()

exitCode

This file was deleted.

2 changes: 0 additions & 2 deletions src/ProjectTemplates/test/template-baselines.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@
"appsettings.Development.json",
"appsettings.json",
"Program.fs",
"Startup.fs",
"WeatherForecast.fs",
"Controllers/WeatherForecastController.fs",
"Properties/launchSettings.json"
Expand Down Expand Up @@ -1142,7 +1141,6 @@
"appsettings.Development.json",
"appsettings.json",
"Program.fs",
"Startup.fs",
"Controllers/HomeController.fs",
"Models/ErrorViewModel.fs",
"Properties/launchSettings.json",
Expand Down

0 comments on commit ba02425

Please sign in to comment.