Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Add IWebHostBuilder.UseKestrel(options) overload to configure Kestrel (#720) #741

Closed
wants to merge 13 commits into from

Conversation

mikeharder
Copy link
Contributor

Src and samples have been changed. Still working on tests. Most diffs are just renames from "information" to "options".

@halter73, @davidfowl, @Tratcher, @DamianEdwards

@davidfowl
Copy link
Member

This looks good to me


namespace Microsoft.AspNetCore.Server.Kestrel
{
public static class KestrelServerOptionsExtensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KestrelServerOptionsHttpsExtensions

@benaadams
Copy link
Contributor

Its less exotic that current, which can only be good

🚀

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Microsoft.AspNetCore.Server.Kestrel.Filter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can bring this into the Microsoft.AspNetCore.Server.Kestrel namespace with the options type. We just didn't want it in the Microsoft.AspNetCore.Builder namespace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it, it doesn't matter if this is in the same namespace as the options type because it's used inside a lamda.

@Tratcher
Copy link
Member

This should be targeting Release, no?

@davidfowl
Copy link
Member

This should be targeting Release, no?

Yep, we spoke about this and @mikeharder will move it to release.

@Tratcher
Copy link
Member

👍

@davidfowl
Copy link
Member

Appveyor seems like a random failure

return hostBuilder.ConfigureServices(services => services.AddSingleton<IServerFactory, ServerFactory>());
}

public static IWebHostBuilder UseKestrel(this IWebHostBuilder hostBuilder, Action<KestrelServerOptions> options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some special reason we need to configure the options via WebHostBuilder rather than doing it in Start.ConfigureServices with a ConfigureKestrel(Action<KestrelServerOptions> options) extension like we'd use for middleware? This won't execute until after ConfigureServices anyways. And then devs can use services injected via Startup's ctor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to split server configuration from application configuration. Of course the user can also configure options in their startup class but this is the default experience we want to preserve. It also keeps the server specific stuff in Program.Main instead of putting it in the user's Startup class by default.

@mikeharder
Copy link
Contributor Author

@davidfowl, @DamianEdwards, @Tratcher, @halter73

What namespaces should we use for the new extension methods UseHttps(this KestrelServerOptions) and UseConnectionLogging(this KestrelServerOptions)?

The typical convention is to put extension methods in the namespace of the object they extend, which would be Microsoft.AspNetCore.Server.Kestrel in this case. However, this may be slightly confusing, since customers could call UseKestrel() without the Kestrel namespace, and many properties would be settable, but the extension methods UseHttps() and UseConnectionLogging() would not be available until they added the Kestrel namespace.

Alternatively, we could put the new extension methods in the same namespace as UseKestrel(), which is Microsoft.AspNetCore.Hosting. However, this breaks the convention of having extension methods in the same namespace as the object they are extending.

@Tratcher
Copy link
Member

Put them in Microsoft.AspNetCore.Server.Kestrel. Trying to guess 2nd degree call sites is going to break down to quickly as there are multiple places you can configure the options.

@mikeharder mikeharder force-pushed the mikeharder/use-kestrel-options branch from 57bf20d to b2cd32d Compare April 13, 2016 18:47
@halter73
Copy link
Member

👍 for Microsoft.AspNetCore.Hosting namespaced KestrelServerOptions*Extensions.

@halter73
Copy link
Member

🚢

…Filter to Kestrel.

Rename class from LoggingFilterKestrelOptionsExtensions to KestrelServerOptionsConnectionLoggingExtensions.
…er needed since the UseConnectionLogging() extension method was moved to Microsoft.AspNetCore.Server.Kestrel.
…strelExtensions, to follow the pattern "<TypeExtended><FunctionalityAdded>Extensions".
Add doc comments to all overloads of UseHttps().
…rnal class in Kestrel namespace to public class in Kestrel.Internal namespace.
@mikeharder mikeharder force-pushed the mikeharder/use-kestrel-options branch from ee57216 to 9515b61 Compare April 13, 2016 21:51
@mikeharder mikeharder closed this Apr 13, 2016
@mikeharder mikeharder deleted the mikeharder/use-kestrel-options branch April 13, 2016 22:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants