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

[breaking change] Rework the server creation API #106

Merged
merged 1 commit into from
Nov 24, 2015

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Nov 23, 2015

Fix #101
Fix #104

The ToSocketAddr trait is specially conceived to be passed to TcpListener::bind, so we should use it directly.

Also, the port 0 seems to be a standard for "a random available port", so there's no need for the with_random_port function anymore.

I went with a public ServerConfig in order to make things explicit. This struct can be extended in the future with things such as client_timeout, ssl (cc #11) or max_clients (cc #26). Users are encouraged to call http instead of new.

Note that I removed the client_timeout parameter because I noticed it was unused anyway.

@tomaka tomaka mentioned this pull request Nov 23, 2015
@@ -25,7 +25,7 @@ fn get_content_type(path: &Path) -> &'static str {

fn main() {
use ascii::AsciiCast;
let server = tiny_http::ServerBuilder::new().with_random_port().build().unwrap();
let server = tiny_http::Server::http("0.0.0.0:0").unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

I know that you didn't change the functionality of this example, but could you change this to not use a random port? It could be the case that the port is less than 1024, which requires super user privileges (at least on unix machines), which could cause the test to fail.

frewsxcv added a commit that referenced this pull request Nov 24, 2015
[breaking change] Rework the server creation API
@frewsxcv frewsxcv merged commit c00b616 into tiny-http:master Nov 24, 2015
@frewsxcv
Copy link
Member

Thanks! Want me to publish a new version or wait for your other PR?

@tomaka
Copy link
Member Author

tomaka commented Nov 24, 2015

Wait for the SSL stuff maybe.

@tomaka tomaka deleted the server-creation branch November 24, 2015 13:37
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.

2 participants