tower/guides/README.md
David Pedersen 77760198f1
docs: add "Building a middleware from scratch" guide (#590)
This adds a guide that explains how to implement a middleware from scratch without taking any shortcuts. It walks through implementing `Timeout` as it exists in Tower today.

The hope is that once users have read [the previous guide](https://tokio.rs/blog/2021-05-14-inventing-the-service-trait) followed by this one they should be fully equipped to implement their own middleware.
2021-06-07 11:06:30 +02:00

28 lines
1.4 KiB
Markdown

# Tower Guides
These guides are meant to be an introduction to Tower. At least basic Rust
experience is assumed. Some experience with asynchronous Rust is also
recommended. If you're brand new to async Rust, we recommend the [Asynchronous
Programming in Rust][async-book] book or the [Tokio tutorial][tokio-tutorial].
Additionally, some of these guides explain Tower from the perspective of HTTP
servers and clients. However, Tower is useful for any network protocol that
follows an async request/response pattern. HTTP is used here because it is a
widely known protocol, and one of Tower's more common use-cases.
## Guides
- ["Inventing the `Service` trait"][invent] walks through how Tower's
fundamental [`Service`] trait could be designed from scratch. If you have no
experience with Tower and want to learn the absolute basics, this is where you
should start.
- ["Building a middleware from scratch"][build] walks through how to build the
[`Timeout`] middleware as it exists in Tower today, without taking any shortcuts.
[async-book]: https://rust-lang.github.io/async-book/
[tokio-tutorial]: https://tokio.rs/tokio/tutorial
[invent]: https://tokio.rs/blog/2021-05-14-inventing-the-service-trait
[build]: https://github.com/tower-rs/tower/blob/master/guides/building-a-middleware-from-scratch.md
[`Service`]: https://docs.rs/tower/latest/tower/trait.Service.html
[`Timeout`]: https://docs.rs/tower/latest/tower/timeout/struct.Timeout.html