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

Allow driving server using user-provided runtime. #19

Merged
merged 1 commit into from
Sep 22, 2018
Merged

Allow driving server using user-provided runtime. #19

merged 1 commit into from
Sep 22, 2018

Conversation

arsing
Copy link
Contributor

@arsing arsing commented Sep 22, 2018

This makes the API more similar to hyper 0.12. Specifically, it allows the user
to use server::Http::serve_* for more fine-grained handling of
incoming connections. The existing server::Server::run still exists to allow
an easy way of synchronously starting up a server on a new tokio runtime.

Other changes:

  • Fix and enable doctests on Server and Http.

  • Fix server example to delete the socket if it exists before binding to it,
    so that it can be run more than once.


Note that this has semver-major breaking changes. Http::bind is now Server::bind (similar to hyper::Server), Server::local_addr always succeeds, and some of the generic bounds are different.

This makes the API more similar to hyper 0.12. Specifically, it allows the user
to use `server::Http::serve_*` for more fine-grained handling of
incoming connections. The existing `server::Server::run` still exists to allow
an easy way of synchronously starting up a server on a new tokio runtime.

Other changes:

- Fix and enable doctests on Server and Http.

- Fix server example to delete the socket if it exists before binding to it,
  so that it can be run more than once.
Copy link
Owner

@softprops softprops left a comment

Choose a reason for hiding this comment

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

Love love love these changes. This looks awesome!

@@ -22,17 +22,22 @@ fn hello(
}

fn run() -> io::Result<()> {
let svr = hyperlocal::server::Http::new().bind("test.sock", || service_fn(hello))?;
match fs::remove_file("test.sock") {
Copy link
Owner

Choose a reason for hiding this comment

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

Nice. I'm been trying come up with a way to impl drop for servers that cleans up the created file. This has been an annoyance when running the example. Thanks for this!

@softprops softprops merged commit 45f6170 into softprops:master Sep 22, 2018
@softprops
Copy link
Owner

@arsing these changes where published in 0.6.0

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