mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-26 00:00:23 +02:00
Update docs with nesting
This commit is contained in:
+21
-9
@@ -3,7 +3,7 @@
|
||||
//!
|
||||
//! ## Goals
|
||||
//!
|
||||
//! - Ease of use. Build web apps in Rust should be as easy as `async fn
|
||||
//! - Ease of use. Building web apps in Rust should be as easy as `async fn
|
||||
//! handle(Request) -> Response`.
|
||||
//! - Solid foundation. tower-web is built on top of tower and makes it easy to
|
||||
//! plug in any middleware from the [tower] and [tower-http] ecosystem.
|
||||
@@ -12,13 +12,6 @@
|
||||
//! - Macro free core. Macro frameworks have their place but tower-web focuses
|
||||
//! on providing a core that is macro free.
|
||||
//!
|
||||
//! ## Non-goals
|
||||
//!
|
||||
//! - Runtime independent. tower-web is designed to work with tokio and hyper
|
||||
//! and focused on bringing a good to experience to that stack.
|
||||
//! - Speed. tower-web is a of course a fast framework, and wont be the
|
||||
//! bottleneck in your app, but the goal is not to top the benchmarks.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! The "Hello, World!" of tower-web is:
|
||||
@@ -500,7 +493,26 @@
|
||||
//!
|
||||
//! # Nesting applications
|
||||
//!
|
||||
//! TODO
|
||||
//! Applications can be nested by calling `nest`:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! use tower_web::{prelude::*, routing::BoxRoute, body::BoxBody};
|
||||
//! use tower_http::services::ServeFile;
|
||||
//! use http::Response;
|
||||
//! use std::convert::Infallible;
|
||||
//! use tower::{service_fn, BoxError};
|
||||
//!
|
||||
//! fn api_routes() -> BoxRoute<BoxBody> {
|
||||
//! route("/users", get(|_: Request<Body>| async { /* ... */ })).boxed()
|
||||
//! }
|
||||
//!
|
||||
//! let app = route("/", get(|_: Request<Body>| async { /* ... */ }))
|
||||
//! .nest("/api", api_routes());
|
||||
//! #
|
||||
//! # async {
|
||||
//! # hyper::Server::bind(&"".parse().unwrap()).serve(tower::make::Shared::new(app)).await;
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! [tower]: https://crates.io/crates/tower
|
||||
//! [tower-http]: https://crates.io/crates/tower-http
|
||||
|
||||
Reference in New Issue
Block a user