summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvsuryamurthy <v.sury@fizyr.com>2024-08-09 20:31:39 +0200
committerGitHub <noreply@github.com>2024-08-09 20:31:39 +0200
commitdd5cbffb5d6d8d24a6326cbd556dd4c1d3e15ddf (patch)
treeccb31be108fcd3d1a81a342149f3847cefafde46
parentc52bf9ebba55b14cc671ecd3a26a9122eb415d1e (diff)
Update extract doc mentioning optional extractors in axum-extra (#2801)
-rw-r--r--axum/src/docs/extract.md6
1 files changed, 6 insertions, 0 deletions
diff --git a/axum/src/docs/extract.md b/axum/src/docs/extract.md
index b3c936c7..0389ca3c 100644
--- a/axum/src/docs/extract.md
+++ b/axum/src/docs/extract.md
@@ -280,6 +280,11 @@ let app = Router::new().route("/users", post(create_user));
# let _: Router = app;
```
+Another option is to make use of the optional extractors in [axum-extra] that
+either returns `None` if there are no query parameters in the request URI,
+or returns `Some(T)` if deserialization was successful.
+If the deserialization was not successful, the request is rejected.
+
# Customizing extractor responses
If an extractor fails it will return a response with the error and your
@@ -709,6 +714,7 @@ logs, enable the `tracing` feature for axum (enabled by default) and the
`axum::rejection=trace` tracing target, for example with
`RUST_LOG=info,axum::rejection=trace cargo run`.
+[axum-extra]: https://docs.rs/axum-extra/latest/axum_extra/extract/index.html
[`body::Body`]: crate::body::Body
[`Bytes`]: crate::body::Bytes
[customize-extractor-error]: https://github.com/tokio-rs/axum/blob/main/examples/customize-extractor-error/src/main.rs