-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add WebApplication.CreateEmptyBuilder #49246
Conversation
Allow an empty WebApplicationBuilder to be created without default behavior. There is no default configuration sources (ex. environment variables or appsettings.json files), no logging, and no web server (ex. Kestrel) configured by default. These can all be added explicitly by the app. The following middleware can be enabled by the app: - Routing and Endpoints, if the app calls MapXXX or registers an EndpointDataSource manually - AuthN/Z, if the app adds the corresponding Auth services - HostFiltering and ForwardedHeaders Fix dotnet#48811
933bdee
to
5cf2861
Compare
src/DefaultBuilder/test/Microsoft.AspNetCore.Tests/WebApplicationTests.cs
Outdated
Show resolved
Hide resolved
Remove Routing from the "Empty" builder. It is up to the app to configure what they want. This is the Empty WebApplication.
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 think the only thing that really needs to be addressed before merging is the hosting startup stuff when configured via the command line.
_genericWebHostServiceDescriptor = InitializeHosting(bootstrapHostBuilder); | ||
} | ||
|
||
internal WebApplicationBuilder(WebApplicationOptions options, bool slim, bool empty, Action<IHostBuilder>? configureDefaults = null) |
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.
Nit: We only have two remaining readonly fields. Is it time to make those non readonly (and possibly "lie" about the nullability), give these more logical method names and remove the weird bool args. E.g. InitializeEmpty
, InitializeSlim
, InitializeFull
?
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.
Let's consider this in a future change. I'm not excited about the factoring now, but it can easily be changed later without breaking anyone.
Respect hosting startup configuration. Refactor to share logic.
Allow an empty WebApplicationBuilder to be created without default behavior. There is no default configuration sources (ex. environment variables or appsettings.json files), no logging, and no web server (ex. Kestrel) configured by default. These can all be added explicitly by the app.
The following middleware can be enabled by the app:
Fix #48811
cc @DamianEdwards @davidfowl