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

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Zarytovskii <vzaritovsky@hotmail.com>2021-09-17 21:13:01 +0300
committerGitHub <noreply@github.com>2021-09-17 21:13:01 +0300
commitba0242544a5e8568853239e3f40cfc87bad61596 (patch)
tree4c84d9c3e0c54cc97e771fe1958178e7e282512f /src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp
parenta94189e39a5fdaf612bada2be7dd7e08a6a861cb (diff)
Use minimal APIs for F# project templates (#35833)
Diffstat (limited to 'src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp')
-rw-r--r--src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs28
-rw-r--r--src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs42
2 files changed, 20 insertions, 50 deletions
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs
index 91d8b747cd..1abd303321 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Program.fs
@@ -1,12 +1,16 @@
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
@@ -14,14 +18,22 @@ 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
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs
deleted file mode 100644
index 1a44dc3b08..0000000000
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs
+++ /dev/null
@@ -1,42 +0,0 @@
-namespace Company.WebApplication1
-
-open System
-open System.Collections.Generic
-open System.Linq
-open System.Threading.Tasks
-open Microsoft.AspNetCore.Builder
-open Microsoft.AspNetCore.Hosting
-#if (!NoHttps)
-open Microsoft.AspNetCore.HttpsPolicy;
-#endif
-open Microsoft.AspNetCore.Mvc
-open Microsoft.Extensions.Configuration
-open Microsoft.Extensions.DependencyInjection
-open Microsoft.Extensions.Hosting
-
-type Startup(configuration: IConfiguration) =
- member _.Configuration = configuration
-
- // This method gets called by the runtime. Use this method to add services to the container.
- member _.ConfigureServices(services: IServiceCollection) =
- // Add framework services.
- services.AddControllers() |> ignore
-
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- member _.Configure(app: IApplicationBuilder, env: IWebHostEnvironment) =
- if (env.IsDevelopment()) then
- app.UseDeveloperExceptionPage() |> ignore
-#if (!NoHttps)
- app.UseHttpsRedirection()
- .UseRouting()
- .UseAuthorization()
- .UseEndpoints(fun endpoints ->
- endpoints.MapControllers() |> ignore
- ) |> ignore
-#else
- app.UseRouting()
- .UseAuthorization()
- .UseEndpoints(fun endpoints ->
- endpoints.MapControllers() |> ignore
- ) |> ignore
-#endif