axum_extra/lib.rs
1//! Extra utilities for [`axum`].
2//!
3//! # Feature flags
4//!
5//! axum-extra uses a set of [feature flags] to reduce the amount of compiled and
6//! optional dependencies.
7//!
8//! The following optional features are available:
9//!
10//! Name | Description | Default?
11//! ---|---|---
12//! `async-read-body` | Enables the [`AsyncReadBody`](crate::body::AsyncReadBody) body | No
13//! `attachment` | Enables the [`Attachment`](crate::response::Attachment) response | No
14//! `cookie` | Enables the [`CookieJar`](crate::extract::CookieJar) extractor | No
15//! `cookie-private` | Enables the [`PrivateCookieJar`](crate::extract::PrivateCookieJar) extractor | No
16//! `cookie-signed` | Enables the [`SignedCookieJar`](crate::extract::SignedCookieJar) extractor | No
17//! `cookie-key-expansion` | Enables the [`Key::derive_from`](crate::extract::cookie::Key::derive_from) method | No
18//! `erased-json` | Enables the [`ErasedJson`](crate::response::ErasedJson) response | No
19//! `error-response` | Enables the [`InternalServerError`](crate::response::InternalServerError) response | No
20//! `form` | Enables the [`Form`](crate::extract::Form) extractor | No
21//! `json-deserializer` | Enables the [`JsonDeserializer`](crate::extract::JsonDeserializer) extractor | No
22//! `json-lines` | Enables the [`JsonLines`](crate::extract::JsonLines) extractor and response | No
23//! `multipart` | Enables the [`Multipart`](crate::extract::Multipart) extractor | No
24//! `protobuf` | Enables the [`Protobuf`](crate::protobuf::Protobuf) extractor and response | No
25//! `query` | Enables the [`Query`](crate::extract::Query) extractor | No
26//! `tracing` | Log rejections from built-in extractors | Yes
27//! `typed-routing` | Enables the [`TypedPath`](crate::routing::TypedPath) routing utilities | No
28//! `typed-header` | Enables the [`TypedHeader`] extractor and response | No
29//! `file-stream` | Enables the [`FileStream`](crate::response::FileStream) response | No
30//!
31//! [`axum`]: https://crates.io/crates/axum
32
33#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
34#![cfg_attr(test, allow(clippy::float_cmp))]
35#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]
36
37#[allow(unused_extern_crates)]
38extern crate self as axum_extra;
39
40pub mod body;
41pub mod either;
42pub mod extract;
43pub mod handler;
44pub mod middleware;
45pub mod response;
46pub mod routing;
47
48#[cfg(feature = "json-lines")]
49pub mod json_lines;
50
51#[cfg(feature = "typed-header")]
52pub mod typed_header;
53
54#[cfg(feature = "typed-header")]
55#[doc(no_inline)]
56pub use headers;
57
58#[cfg(feature = "typed-header")]
59#[doc(inline)]
60pub use typed_header::TypedHeader;
61
62#[cfg(feature = "protobuf")]
63pub mod protobuf;
64
65/// _not_ public API
66#[cfg(feature = "typed-routing")]
67#[doc(hidden)]
68pub mod __private {
69 use percent_encoding::{AsciiSet, CONTROLS};
70
71 pub use percent_encoding::utf8_percent_encode;
72
73 // from https://github.com/servo/rust-url/blob/master/url/src/parser.rs
74 const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
75 const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}');
76 pub const PATH_SEGMENT: &AsciiSet = &PATH.add(b'/').add(b'%');
77}
78
79#[cfg(test)]
80use axum_macros::__private_axum_test as test;
81
82#[cfg(test)]
83pub(crate) use axum::test_helpers;