Closed Banyc closed 1 year ago
This really isn't a carter request, you want to be able to run asp.net core as a background service. Carter builds on ASP.NET Core and shouldn't need to build anything like this.
You can already do this today by using the existing ASP.NET Core extension method ConfigureWebHost
or ConfigureWebHostDefaults
.
Motivation
REST servers should be treated the same as user defined services. The nowadays usage of the REST functionality heavily relies on WebApplicationBuilder, a web-centric design. But, in fact, the REST server is a remote process interface, no difference than the message queue adaptors for Kafka, RabbitMQ alike or than grpc. In the original version, the message queue adapters look inappropriately inferior to the mere REST server.
Also, WebApplication is in itself a IHostedService as illustrated here (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-6.0#:~:text=a%20web%20app%2C-,one%20of,-the%20IHostedService%20implementations) and demonstrated here (https://github.dev/dotnet/aspnetcore/blob/ab80f42b175c8fdace4198a1cdcd3f856b2544e6/src/Hosting/Hosting/src/GenericHostWebHostBuilderExtensions.cs#L61). Aided with the principle of decoupling, It could be another feasible motive to back this proposal.
Desired API
Reference
https://github.com/dotnet/aspnetcore/issues/39215