@@ -5,7 +5,7 @@ layout: guide
5
5
6
6
Let's start by making a "Hello, World!" server, and expand from there.
7
7
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 ` :
9
9
10
10
``` toml
11
11
[dependencies ]
@@ -43,7 +43,7 @@ incoming requests. It represents an async function that takes a
43
43
future is complete, it will resolve to a [ ` Response ` ] [ response ] or an error.
44
44
45
45
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
47
47
a service from our ` hello ` function below when we're ready to start our
48
48
server.
49
49
@@ -67,7 +67,7 @@ set automatically.
67
67
68
68
## Starting the Server
69
69
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.
71
71
72
72
We'll dive in to the specifics of some of these things in another guide.
73
73
@@ -126,26 +126,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
126
126
127
127
To see all the snippets put together, check out the [ full example] [ example ] !
128
128
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
+
129
134
This example uses the ` http1 ` module to create a server that speaks HTTP/1.
130
135
In case you want to use HTTP/2, you can use the ` http2 ` module with a few changes to the
131
136
http1 server. The http2 builder requires an executor to run. Executor should implement the ` hyper::rt::Executor ` trait.
132
137
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 ] !
149
140
150
141
[ service] : {{ site.hyper_docs_url }}/hyper/service/trait.Service.html
151
142
[ 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
154
145
[ parts] : {{ site.http_docs_url }}/http/response/struct.Parts.html
155
146
[ example] : {{ site.examples_url }}/hello.rs
156
147
[ example_http2] : {{ site.examples_url }}/hello-http2.rs
148
+ [ runtime ] : ../init/runtime.md
157
149
[ impl service] : {{ site.examples_url }}/service_struct_impl.rs
0 commit comments