axum/examples/customize-extractor-error
Zheng Li 19101f624d
Replace async_trait with AFIT / RPITIT (#2308)
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2024-09-28 21:27:11 +00:00
..
src Replace async_trait with AFIT / RPITIT (#2308) 2024-09-28 21:27:11 +00:00
Cargo.toml Don't depend on axum-macros in examples (#2122) 2023-07-26 20:21:39 +02:00
README.md Fix typo on customize-extractor-error example (#2124) 2023-07-27 14:03:10 +00:00

This example explores 3 different ways you can create custom rejections for already existing extractors

  • with_rejection: Uses axum_extra::extract::WithRejection to transform one rejection into another
  • derive_from_request: Uses the axum::extract::FromRequest derive macro to wrap another extractor and customize the rejection
  • custom_extractor: Manual implementation of FromRequest that wraps another extractor

Run with

cargo run -p example-customize-extractor-error