Skip to content

Commit b28e497

Browse files
committed
Implemented suggestions
1 parent 6e90aab commit b28e497

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

_stable/server/hello-world.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ layout: guide
55

66
Let's start by making a "Hello, World!" server, and expand from there.
77

8-
First we need to declare our dependencies, let's add the following to our `Cargo.toml`:
8+
First, we need to declare our dependencies, let's add the following to our `Cargo.toml`:
99

1010
```toml
1111
[dependencies]
@@ -43,7 +43,7 @@ incoming requests. It represents an async function that takes a
4343
future is complete, it will resolve to a [`Response`][response] or an error.
4444

4545
Hyper provides a utility for creating a `Service` from a function that should
46-
serve most usecases: [`service_fn`][service_fn]. We will use this to create
46+
serve most use cases: [`service_fn`][service_fn]. We will use this to create
4747
a service from our `hello` function below when we're ready to start our
4848
server.
4949

@@ -67,7 +67,7 @@ set automatically.
6767

6868
## Starting the Server
6969

70-
Lastly, we need to hook up our `hello` service into a running hyper server.
70+
Lastly, we need to hook up our `hello` service into a running Hyper server.
7171

7272
We'll dive in to the specifics of some of these things in another guide.
7373

@@ -126,26 +126,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
126126

127127
To see all the snippets put together, check out the [full example][example]!
128128

129+
Also, if `service_fn` doesn't meet your requirements and you'd like to implement
130+
`Service` yourself, see this [example][impl service].
131+
132+
## HTTP/2
133+
129134
This example uses the `http1` module to create a server that speaks HTTP/1.
130135
In case you want to use HTTP/2, you can use the `http2` module with a few changes to the
131136
http1 server. The http2 builder requires an executor to run. Executor should implement the `hyper::rt::Executor` trait.
132137

133-
```rust
134-
impl<F> hyper::rt::Executor<F> for TokioExecutor
135-
where
136-
F: std::future::Future + Send + 'static,
137-
F::Output: Send + 'static,
138-
{
139-
fn execute(&self, fut: F) {
140-
tokio::task::spawn(fut);
141-
}
142-
}
143-
```
144-
145-
The see the full example with HTTP/2, check out the [full example][example_http2]!
146-
147-
Also, if `service_fn` doesn't meet your requirements and you'd like to implement
148-
`Service` yourself, see this [example][impl service].
138+
To implement the Executor, check out the runtime [example][runtime].
139+
To see the full example with HTTP/2, check out the [full example][example_http2]!
149140

150141
[service]: {{ site.hyper_docs_url }}/hyper/service/trait.Service.html
151142
[service_fn]: {{ site.hyper_docs_url }}/hyper/service/fn.service_fn.html
@@ -154,4 +145,5 @@ Also, if `service_fn` doesn't meet your requirements and you'd like to implement
154145
[parts]: {{ site.http_docs_url }}/http/response/struct.Parts.html
155146
[example]: {{ site.examples_url }}/hello.rs
156147
[example_http2]: {{ site.examples_url }}/hello-http2.rs
148+
[runtime]: ../init/runtime.md
157149
[impl service]: {{ site.examples_url }}/service_struct_impl.rs

0 commit comments

Comments
 (0)