forked from dotnet/aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use minimal APIs for F# project templates (dotnet#35833)
- Loading branch information
1 parent
a94189e
commit ba02425
Showing
7 changed files
with
55 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 35 additions & 7 deletions
42
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Program.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
55 changes: 0 additions & 55 deletions
55
src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs
This file was deleted.
Oops, something went wrong.
28 changes: 20 additions & 8 deletions
28
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
42 changes: 0 additions & 42 deletions
42
src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters