axum/examples/customize-extractor-error
tottoto 6c133be5b7
Refactor initializing tracing-subscriber in examples (#1596)
* Refactor initializing tracing-subscriber

* Revert "Refactor initializing tracing-subscriber"

This reverts commit 0876260bf9 in favor of tracing_subscriber::registry.

* Use EnvFilter::try_from_default_env in chat example

* Use EnvFilter::try_from_default_env in examples
2022-11-30 10:46:19 +01:00
..
src Refactor initializing tracing-subscriber in examples (#1596) 2022-11-30 10:46:19 +01:00
Cargo.toml Extend custom rejection examples (#1276) 2022-08-19 13:11:03 +00:00
README.md Extend custom rejection examples (#1276) 2022-08-19 13:11:03 +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 axum_macros::FromRequest to wrap another extractor and customize the rejection
  • custom_extractor: Manual implementation of FromRequest that wraps another extractor

Run with

cd examples && cargo run -p example-customize-extractor-error