-
Notifications
You must be signed in to change notification settings - Fork 84
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
Update ASP.NET Core sample to use minimal host #283
Update ASP.NET Core sample to use minimal host #283
Conversation
CE-SpecVersion: 1.0 | ||
CE-Type: "com.example.myevent" | ||
CE-Source: "urn:example-com:mysource:abc" | ||
CE-Id: "c457b7c5-c038-4be9-98b9-938cb64a4fbf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an ideal world, I wouldn't hardcode the GUID here and would instead use dynamic variable support provided by .http
files. However, it appears that each editor recognizes a different dynamic variable for generating a GUID.
VS Code and VS respect {{$guid}}
and Rider respects {{$random.uuid}}
so there is no universal value to include here. Opted to hard code for now.
63ed6b5
to
ae5b5a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely happy to use the more modern style of app startup.
Does anything use the new .http file? (It's not something I've come across before, and I'm not sure whether it's used implicitly or whether it's just as an example that has some IDE support for "send this request".) It might be worth a README file in this directory.
namespace CloudNative.CloudEvents.AspNetCoreSample | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddControllers(opts => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an expression-bodied lambda here?
(I've always found it unusual that so many MS docs use a block-bodied lambda for ASP.NET Core option actions, even when there's only a single statement. Admittedly that makes it easier to add more statements, but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an expression-bodied lambda here?
Sure! I don't mind using something terser here.
Rider and VS provide built-in support for executing the requests in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much, the readme in particular is great!
@@ -0,0 +1,44 @@ | |||
# Samples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing!
Doh - one thing, we need each commit to have a "Signed-off-by" line. If you could squash the two commits down to one that contains the Signed-off-by, I'll then merge. Thanks! |
Signed-off-by: Safia Abdalla <safia@safia.rocks>
Signed-off-by: Safia Abdalla <safia@safia.rocks>
fc32041
to
2863974
Compare
Woop -- I ended up signing the second commit and force-pushing. If you'd prefer I squash let me know. |
Fingers crossed it'll be fine - I'll squash it myself as part of merging, which I think should work... |
Build failure! Embarrassing 🙊 I'll fix this |
Signed-off-by: Safia Abdalla <safia@safia.rocks>
This updates the ASP.NET Core sample to use some of the "modern" functionality available in .NET 6+ including top-level statements, the new minimal-style
WebApplicationBuilder
, and removal of theStartup
class.I've also included an
.http
file to support testing of the endpoint.As a next step, I'd like to take a stab at replacing the controller class + input formatter with a minimal endpoint +
BindAsync
implementation, but I think this change is helpful for now.