Skip to content

Commit

Permalink
Show WebApplicationBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Apr 21, 2021
1 parent a8de4b4 commit a295dc3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/Http/samples/MinimalSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
app.UseDeveloperExceptionPage();
}

app.MapGet("/", (Func<string>)(() => "Hello World!"));

string Plaintext() => "Hello, World!";
app.MapGet("/plaintext", (Func<string>)Plaintext);

object Json() => new { message = "Hello, World!" };
app.MapGet("/json", (Func<object>)Json);

string SayHello(string name) => $"Hello {name}";
string SayHello(string name) => $"Hello, {name}!";
app.MapGet("/hello/{name}", (Func<string, string>)SayHello);

await app.RunAsync();
4 changes: 2 additions & 2 deletions src/Http/samples/MinimalSampleFSharp/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ open Microsoft.Extensions.Hosting

[<EntryPoint>]
let main args =
let app = WebApplication.Create(args);
use app = WebApplication.Create(args)

if app.Environment.IsDevelopment() then
app.UseDeveloperExceptionPage() |> ignore

app.MapGet("/plaintext", Func<string>(fun () -> "Hello, World!")) |> ignore
app.MapGet("/json", Func<obj>(fun () -> upcast {| message = "Hello, World!" |})) |> ignore
app.MapGet("/hello/{name}", Func<string, string>(fun name -> $"Hello {name}")) |> ignore
app.MapGet("/hello/{name}", Func<string, string>(fun name -> $"Hello, {name}!")) |> ignore

app.Run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;

await using var app = WebApplication.Create(args);
var builder = WebApplication.CreateBuilder(args);
await using var app = builder.Build();

if (app.Environment.IsDevelopment())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ open Microsoft.Extensions.Hosting

[<EntryPoint>]
let main args =
let app = WebApplication.Create(args);
let builder = WebApplication.CreateBuilder(args)
use app = builder.Build()

if app.Environment.IsDevelopment() then
app.UseDeveloperExceptionPage() |> ignore
Expand Down

0 comments on commit a295dc3

Please sign in to comment.