Skip to content
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

make creation of http server by polka optional #13

Closed
wants to merge 5 commits into from
Closed

make creation of http server by polka optional #13

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 20, 2018

Polka would create floating unused http server if people decided to use own like https or native written in C or other langs
by adding { createServer: true/false (default true) } option it allows to control creation of internal server

I wasn't sure what to include in start method promise rejection if server doesn't exist so I leave it for you to decide

@@ -30,7 +32,7 @@ class Polka extends Router {

start(port, hostname) {
return new Promise((res, rej) => {
this.server.listen(port, hostname, err => err ? rej(err) : res());
this.server ? this.server.listen(port, hostname, err => err ? rej(err) : res()) : rej();
Copy link
Author

Choose a reason for hiding this comment

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

I am thinking of rej('internal server disabled by options')

@ghost ghost mentioned this pull request Jan 20, 2018
@lukeed
Copy link
Owner

lukeed commented Jan 20, 2018

Hey, thanks! Will take some time to review as I figure out where I want Polka to go.

For the record though, re: #12 (comment), you can already wrap Polka with your own HTTP(S) server. The underlying server is only used/running if you call start/listen on Polka directly.

Please see the with-https example if you haven't already. Thanks!

@ghost
Copy link
Author

ghost commented Jan 20, 2018

I acknowledged that it only listens if start is called but it still creates http server each time new class is created under .server property and that floats without usage.
Also, unused http servers number increases as more sub-apps are added

@ghost ghost closed this Mar 3, 2018
@ghost ghost mentioned this pull request Mar 3, 2018
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant