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

accept host and port as envvars #25

Open
ashleygwilliams opened this issue Oct 15, 2017 · 6 comments
Open

accept host and port as envvars #25

ashleygwilliams opened this issue Oct 15, 2017 · 6 comments

Comments

@ashleygwilliams
Copy link
Collaborator

No description provided.

@steveklabnik
Copy link
Owner

This is basically upgrading the examples, right? This is already supported by the library.

@ashleygwilliams
Copy link
Collaborator Author

ah i was thinking we could bake it in, but that's probably not necessary (like include dotenv and stuff). i'm gonna leave this open cuz it might be nice, but it's not urgent.

we might add defaults?

i was thinking something like host and port are optional and they default to:

  • 0.0.0.0 || process.env.HOST
  • 7878 || process.env.POST

@steveklabnik
Copy link
Owner

steveklabnik commented Oct 15, 2017

So, the trick there is that Rust doesn't have default arguments, so you'd have to make a second method that had no arguments and used the vars by default.

We could change it to something like this too:

let mut server = Server::new();

server.set_host("0.0.0.0");
server.set_port("7878");

server.listen();

And then if you wanted to use the fallback, you could not call set_host and set_port. Thoughts?

@ashleygwilliams
Copy link
Collaborator Author

ah yeah this seems like a nice idea

@hagsteel
Copy link

I would argue that using 0.0.0.0 as default is not as safe as using 127.0.0.1.
This means that the web server is instantly accessible on your network and if you do happen to have port forwarding on it would become exposed online, so defaulting to 127.0.0.1 is safer.

@steveklabnik
Copy link
Owner

@jonashagstedt yeah I always forget which one is the good one and which one isn't; we should default to the good one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants