Skip to content

Commit

Permalink
docs: fix Reject example compiler failure
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Dec 29, 2021
1 parent 6570576 commit 969d10a
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! #[derive(Debug)]
//! struct InvalidParameter;
//!
//! impl reject::Reject for InvalidParameter {};
//! impl reject::Reject for InvalidParameter {}
//!
//! // Custom rejection handler that maps rejections into responses.
//! async fn handle_rejection(err: Rejection) -> Result<impl Reply, std::convert::Infallible> {
Expand All @@ -42,23 +42,18 @@
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//!
//! // Filter on `/:id`, but reject with InvalidParameter if the `id` is `0`.
//! // Recover from this rejection using a custom rejection handler.
//! let route = warp::path::param()
//! .and_then(|id: u32| async move {
//! if id == 0 {
//! Err(warp::reject::custom(InvalidParameter))
//! } else {
//! Ok("id is valid")
//! }
//! })
//! .recover(handle_rejection);
//!
//! warp::serve(route).run(([127, 0, 0, 1], 3030)).await;
//! }
//! // Filter on `/:id`, but reject with InvalidParameter if the `id` is `0`.
//! // Recover from this rejection using a custom rejection handler.
//! let route = warp::path::param()
//! .and_then(|id: u32| async move {
//! if id == 0 {
//! Err(warp::reject::custom(InvalidParameter))
//! } else {
//! Ok("id is valid")
//! }
//! })
//! .recover(handle_rejection);
//! ```

use std::any::Any;
Expand Down

0 comments on commit 969d10a

Please sign in to comment.