]> git.proxmox.com Git - rustc.git/blame - src/doc/book/src/ch20-00-final-project-a-web-server.md
New upstream version 1.37.0+dfsg1
[rustc.git] / src / doc / book / src / ch20-00-final-project-a-web-server.md
CommitLineData
13cf67c4
XL
1# Final Project: Building a Multithreaded Web Server
2
3It’s been a long journey, but we’ve reached the end of the book. In this
4chapter, we’ll build one more project together to demonstrate some of the
5concepts we covered in the final chapters, as well as recap some earlier
6lessons.
7
8For our final project, we’ll make a web server that says “hello” and looks like
9Figure 20-1 in a web browser.
10
11![hello from rust](img/trpl20-01.png)
12
13<span class="caption">Figure 20-1: Our final shared project</span>
14
15Here is the plan to build the web server:
16
171. Learn a bit about TCP and HTTP.
182. Listen for TCP connections on a socket.
193. Parse a small number of HTTP requests.
204. Create a proper HTTP response.
215. Improve the throughput of our server with a thread pool.
22
23But before we get started, we should mention one detail: the method we’ll use
24won’t be the best way to build a web server with Rust. A number of
dc9dc135
XL
25production-ready crates are available on [crates.io](https://crates.io/) that
26provide more complete web server and thread pool implementations than we’ll
27build.
13cf67c4
XL
28
29However, our intention in this chapter is to help you learn, not to take the
30easy route. Because Rust is a systems programming language, we can choose the
31level of abstraction we want to work with and can go to a lower level than is
32possible or practical in other languages. We’ll write the basic HTTP server and
33thread pool manually so you can learn the general ideas and techniques behind
34the crates you might use in the future.