[HttpSys] Move to GenericHost (#24285)
This commit is contained in:
parent
b094ecddf0
commit
64b5ea9393
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.HttpSys;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace HotAddSample
|
||||
|
|
@ -96,15 +98,19 @@ namespace HotAddSample
|
|||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
public static Task Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
var host = new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
webHostBuilder
|
||||
.UseStartup<Startup>()
|
||||
.UseHttpSys();
|
||||
})
|
||||
.ConfigureLogging(factory => factory.AddConsole())
|
||||
.UseStartup<Startup>()
|
||||
.UseHttpSys()
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
return host.RunAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Hosting.Server.Features;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}, app);
|
||||
}
|
||||
|
||||
internal static IWebHost CreateDynamicHost(AuthenticationSchemes authType, bool allowAnonymous, out string root, RequestDelegate app)
|
||||
internal static IHost CreateDynamicHost(AuthenticationSchemes authType, bool allowAnonymous, out string root, RequestDelegate app)
|
||||
{
|
||||
return CreateDynamicHost(string.Empty, out root, out var baseAddress, options =>
|
||||
{
|
||||
|
|
@ -75,22 +76,26 @@ namespace Microsoft.AspNetCore.Server.HttpSys
|
|||
}, app);
|
||||
}
|
||||
|
||||
internal static IWebHost CreateDynamicHost(out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app)
|
||||
internal static IHost CreateDynamicHost(out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app)
|
||||
{
|
||||
return CreateDynamicHost(string.Empty, out var root, out baseAddress, configureOptions, app);
|
||||
}
|
||||
|
||||
internal static IWebHost CreateDynamicHost(string basePath, out string root, out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app)
|
||||
internal static IHost CreateDynamicHost(string basePath, out string root, out string baseAddress, Action<HttpSysOptions> configureOptions, RequestDelegate app)
|
||||
{
|
||||
var prefix = UrlPrefix.Create("http", "localhost", "0", basePath);
|
||||
|
||||
var builder = new WebHostBuilder()
|
||||
.UseHttpSys(options =>
|
||||
var builder = new HostBuilder()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
options.UrlPrefixes.Add(prefix);
|
||||
configureOptions(options);
|
||||
})
|
||||
.Configure(appBuilder => appBuilder.Run(app));
|
||||
webHostBuilder
|
||||
.UseHttpSys(options =>
|
||||
{
|
||||
options.UrlPrefixes.Add(prefix);
|
||||
configureOptions(options);
|
||||
})
|
||||
.Configure(appBuilder => appBuilder.Run(app));
|
||||
});
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue