Skip to content

Update hyper example #9

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/getting_started/http_server_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Let's add some dependencies to the `Cargo.toml` file:
# The latest version of the "futures" library, which has lots of utilities
# for writing async code. Enable the "tokio-compat" feature to include the
# functions for using futures 0.3 and async/await with the Tokio library.
futures-preview = { version = "0.3.0-alpha.9", features = ["tokio-compat"] }
futures-preview = { version = "0.3.0-alpha.13", features = ["compat"] }

# Hyper is an asynchronous HTTP library. We'll use it to power our HTTP
# server and to make HTTP requests.
hyper = "0.12.9"
hyper = "0.12.25"

# Tokio is a runtime for asynchronous I/O applications. Hyper uses
# it for the default server runtime. The `tokio` crate also provides an
# an `await!` macro similar to the one in `std`, but it supports `await!`ing
# both futures 0.1 futures (the kind used by Hyper and Tokio) and
# futures 0.3 futures (the kind produced by the new `async`/`await!` language
# feature).
tokio = { version = "0.1.11", features = ["async-await-preview"] }
tokio = { version = "0.1.16", features = ["async-await-preview"] }
```

Now that we've got our dependencies out of the way, let's start writing some
Expand Down Expand Up @@ -61,10 +61,6 @@ use {
rt::run,
},
futures::{
// `TokioDefaultSpawner` tells futures 0.3 futures how to spawn tasks
// onto the Tokio runtime.
compat::TokioDefaultSpawner,

// Extension traits providing additional methods on futures.
// `FutureExt` adds methods that work for all futures, whereas
// `TryFutureExt` adds methods to futures that return `Result` types.
Expand Down Expand Up @@ -101,7 +97,7 @@ async fn run_server(addr: SocketAddr) {
// wrapper to go from a futures 0.3 future (the kind returned by
// `async fn`) to a futures 0.1 future (the kind used by Hyper).
.serve(|| service_fn(|req|
serve_req(req).boxed().compat(TokioDefaultSpawner)
serve_req(req).boxed().compat()
));

// Wait for the server to complete serving or exit with an error.
Expand All @@ -122,7 +118,7 @@ fn main() {
// futures 0.1 future.
let futures_03_future = run_server(addr);
let futures_01_future =
futures_03_future.unit_error().boxed().compat(TokioDefaultSpawner);
futures_03_future.unit_error().boxed().compat();

// Finally, we can run the future to completion using the `run` function
// provided by Hyper.
Expand Down