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

Honor PreferHostingUrls #1639

Closed
wants to merge 4 commits into from
Closed

Honor PreferHostingUrls #1639

wants to merge 4 commits into from

Conversation

JunTaoLuo
Copy link
Contributor

Addresses #1575.

We want to override the endpoints configured in the listen options when PreferHostingUrls is set to true with the addresses in the IServerAddressesFeature if it's not empty.

Will squash with a meaningful commit message once ready to merge.

@davidfowl
Copy link
Member

nit: English spelling of Honour 😉

@@ -131,8 +131,15 @@ public void Start<TContext>(IHttpApplication<TContext> application)

return;
}
else if (!hasListenOptions)
else if (!hasListenOptions || (_serverAddresses.PreferHostingUrls && hasServerAddresses))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a big fan of how these if else are structured since it's somewhat convoluted. As far as I can tell, it's to reduce code duplication for translating server addresses to listen options and binding to the listen options.

I have an alternative approach added to the branch at https://github.com/aspnet/KestrelHttpServer/compare/johluo/use-hosting-urls?diff=split&expand=1&name=johluo%2Fuse-hosting-urls but there's a bit of moving things around so I'm not sure if it's worth the effort.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the alternative approach; it's easier to follow the logic in that version.

{
services.AddSingleton<ILoggerFactory>(new KestrelTestLoggerFactory(testLogger));
})
.UseLoggerFactory(_ => new KestrelTestLoggerFactory(testLogger))
Copy link
Member

Choose a reason for hiding this comment

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

Why not use the overload that takes an instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were thinking of obsoleting that overload. aspnet/Hosting#1007. We want to use the overloads that also take in the WebHostBuilderContext.

@JunTaoLuo JunTaoLuo requested a review from pakrym April 10, 2017 17:36
@muratg muratg changed the title Honour PreferHostingUrls Honor PreferHostingUrls Apr 10, 2017
@JunTaoLuo
Copy link
Contributor Author

JunTaoLuo commented Apr 11, 2017

closing in favour of #1655

@JunTaoLuo JunTaoLuo closed this Apr 11, 2017
@natemcmaster natemcmaster deleted the johluo/use-hosting-urls-alt branch June 12, 2017 21:50
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.

4 participants