-
Notifications
You must be signed in to change notification settings - Fork 312
Hosting API followup #530
Comments
Since we have the helper that creates the right
It is too verbose, I do worry about having
Once we cover those 3 we're good.
That's a valid reason to return void. Today it does look like you can restart the server by calling start again after dispose. We should have a sample showing how to restart a server, that's something we didn't have guidance on in the past and should be solved with this API do-over. I think this API this ugly: var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
using (application)
{
application.Start();
Console.ReadLine();
}
Please not Start/Run on the builder that doesn't seem right. Passing the list of addresses to Start/Run seems cleaner but then we might end up in overload hell again when we figure out we want to pass more things to the server (random other server config?). |
Not only is this ugly, it's also not recommended since application is still in scope after the closing brace of the using statement. User can still call member functions on application which, since |
-2 points for that pattern. We should work on the restart pattern and the pattern that throws if you start more than once. That's a good compromise. |
Restart? The current restart pattern is to throw everything away and start from scratch. What would you want to re-use? |
Well is it? Even the builder? We should write a few samples showing that. |
Is there any more to this issue after #553? |
Seems like there isn't any more to do in this issue, closing for now. |
Continuing discussion on items left over from #525
Currently we use recommend using
builder.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
. This is verbose. One suggestion for this is to add aUseConfiguration(string[] args)
overload for only command line configs. Also, there is some contention on whether environment variables and hosting.json configurations should be enabled by default.There are two suggestions for
WebApplication.Start()
. We currently use the IDisposable pattern which lends itself to a convenient patternusing(app.Start()){ ... }
where we handle shutdown throughDispose()
. However, since we do not support an application being started more than once, it is natural to returnvoid
. This leads to less desirable usage patterns however, such asusing(var app = builder.Build()){app.Start(); ... }
.Currently we build an application using a builder, configure that application (such as setting addresses), then run or start the application. There is a suggestion on making address configuration more first class on the
WebApplicationBuilder
and directly callingStart()
orRun()
on the builder but this will require shuffling of startup since Addresses are currently ServerFeatures that are only available after the WebApplication is built. It's also suggested to possibly add overloads toStart()
andRun()
to take in a list of addresses to listen on.Some of the current exception messages need to be updated. For example, the message at StartupLoader.cs#L46 can be cryptic. For this exception in particular, it should be determined if it's the responsibility of the
WebApplication
or theStartupLoader
, which could be third party, to throw exception to the user.The text was updated successfully, but these errors were encountered: