-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation around minimal usage of Hello World in Giraffe #497
Comments
Unfortunately not but I think Saturn, which is a wrapper around Giraffe has a similar experience:
|
+1 to what Dustin has said, what you are asking for is one of the goals Saturn has. Here is what a minimal hosting bootstrapping for Giraffe might look like (works with .NET 6 & Giraffe 6.0.0-alpha-2): open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Hosting
open Giraffe
let builder = WebApplication.CreateBuilder()
builder.Services.AddGiraffe() |> ignore
let app = builder.Build()
app.UseGiraffe(text "Hello World!")
app.Run() |
@dustinmoris the example that @slang25 has looks pretty minimal. It would be really nice to have it documented since it shows what you can do with Giraffe 😄 |
I discovered this issue trying to get Giraffe set up with .NET 7. It was super helpful to see how to do it here, but it'd be even better if it was documented in the readme or docs. P.S. thanks for the great framework! |
Send a PR and I’ll merge it! |
Any thoughts on where to put the documentation? I've added some PRs related to minimal API code on the samples repository. |
After some reflection, I'm not sure the example provided above is as comparable to the minimal api docs link provided above. For example: var app = WebApplication.Create(args);
app.MapGet("/", () => "Hello World!");
app.Run(); Shows three things.
By contrast: let builder = WebApplication.CreateBuilder()
builder.Services.AddGiraffe() |> ignore
let app = builder.Build()
app.UseGiraffe(text "Hello World!")
app.Run() It does, 1 and 3, but doesn't do number 2. Given this example, how would I add an additional post route? We do have this basic starting example, it's not as cute as the minimal api example, and probably could be trimmed up based on the example provided but I think also showing how routes get created and being able to add them easily is a better route than playing code golf. |
I agree that the example you show is better. Perhaps the reason why you have MapGet as a thing directly is because that is a route declaration. |
I've updated the sample to be: open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Hosting
open Giraffe
let builder = WebApplication.CreateBuilder()
builder.Services.AddGiraffe() |> ignore
let app = builder.Build()
let webApp =
choose [
route "/ping" >=> text "pong"
route "/" >=> text "Hello World" ]
app.UseGiraffe(webApp)
app.Run() since that is more in line with the intent of MapGet. |
I think GETs at what I was thinking in my HEAD. Would you PUT that in the PR? |
I've updated the PR as can be seen here: |
Since the minimal hosting API is relatively new, I had to upgrade to net7 as well: |
Is there a way to use Giraffe in the same style as seen with Suave:
?
Especially since we have seen marketing around minimal APIs for C#.
The text was updated successfully, but these errors were encountered: