Skip to content

[HttpSys] Move to GenericHost #24285

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

Merged
merged 1 commit into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Servers/HttpSys/samples/HotAddSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -96,15 +98,19 @@ public void Configure(IApplicationBuilder app)
});
}

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();
}
}
}
23 changes: 14 additions & 9 deletions src/Servers/HttpSys/test/FunctionalTests/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -66,7 +67,7 @@ internal static IServer CreateHttpAuthServer(AuthenticationSchemes authType, boo
}, 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 =>
{
Expand All @@ -75,22 +76,26 @@ internal static IWebHost CreateDynamicHost(AuthenticationSchemes authType, bool
}, 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();

Expand Down