|
25 | 25 | //! elegant-departure = { version = "0.2", features = "tokio" }
|
26 | 26 | //! ```
|
27 | 27 | //!
|
| 28 | +//! # Example: Axum |
| 29 | +//! |
| 30 | +//! Axum is easily integrated through the `tokio` integration. |
| 31 | +//! |
| 32 | +//! ```no_run |
| 33 | +//! use axum::{routing::get, Router}; |
| 34 | +//! |
| 35 | +//! #[tokio::main] |
| 36 | +//! async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 37 | +//! let app = Router::new().route("/", get(|| async { "Hello, World!" })); |
| 38 | +//! |
| 39 | +//! println!("Listening on port 3000!"); |
| 40 | +//! let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await?; |
| 41 | +//! |
| 42 | +//! axum::serve(listener, app) |
| 43 | +//! .with_graceful_shutdown(elegant_departure::tokio::depart().on_termination()) |
| 44 | +//! .await?; |
| 45 | +//! |
| 46 | +//! Ok(()) |
| 47 | +//! } |
| 48 | +//! ``` |
| 49 | +//! |
28 | 50 | //! # Example: Simple worker
|
29 | 51 | //!
|
30 | 52 | //! A minimal example with multiple workers getting notified on shutdown.
|
|
110 | 132 | //! More examples can be found in the [examples] directory of the source code repository:
|
111 | 133 | //!
|
112 | 134 | //! - [Simple]: the full simple example from above
|
| 135 | +//! - [Axum]: the full axum example from above |
113 | 136 | //! - [Tokio]: the full tokio example from above
|
114 | 137 | //! - [Hyper]: a shutdown example using the Hyper webserver
|
115 | 138 | //! - [Worker]: example implementation of a worker using `select!`
|
|
118 | 141 | //!
|
119 | 142 | //! [examples]: https://github.com/Dav1dde/elegant-departure/tree/master/examples
|
120 | 143 | //! [Simple]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/simple.rs
|
| 144 | +//! [Axum]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/axum.rs |
121 | 145 | //! [Tokio]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/tokio.rs
|
122 | 146 | //! [Hyper]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/hyper.rs
|
123 | 147 | //! [Worker]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/worker.rs
|
|
0 commit comments