2021-11-17 21:00:32 +01:00
|
|
|
//! Extra utilities for [`axum`].
|
|
|
|
|
//!
|
2022-06-10 08:46:09 +02:00
|
|
|
//! # Feature flags
|
|
|
|
|
//!
|
|
|
|
|
//! axum-extra uses a set of [feature flags] to reduce the amount of compiled and
|
|
|
|
|
//! optional dependencies.
|
|
|
|
|
//!
|
|
|
|
|
//! The following optional features are available:
|
|
|
|
|
//!
|
|
|
|
|
//! Name | Description | Default?
|
|
|
|
|
//! ---|---|---
|
2024-11-16 11:14:51 +01:00
|
|
|
//! `async-read-body` | Enables the [`AsyncReadBody`](crate::body::AsyncReadBody) body | No
|
2024-11-24 01:02:05 +01:00
|
|
|
//! `attachment` | Enables the [`Attachment`](crate::response::Attachment) response | No
|
2024-11-16 11:14:51 +01:00
|
|
|
//! `cookie` | Enables the [`CookieJar`](crate::extract::CookieJar) extractor | No
|
|
|
|
|
//! `cookie-private` | Enables the [`PrivateCookieJar`](crate::extract::PrivateCookieJar) extractor | No
|
|
|
|
|
//! `cookie-signed` | Enables the [`SignedCookieJar`](crate::extract::SignedCookieJar) extractor | No
|
|
|
|
|
//! `cookie-key-expansion` | Enables the [`Key::derive_from`](crate::extract::cookie::Key::derive_from) method | No
|
|
|
|
|
//! `erased-json` | Enables the [`ErasedJson`](crate::response::ErasedJson) response | No
|
2024-12-01 10:44:43 +00:00
|
|
|
//! `error-response` | Enables the [`InternalServerError`](crate::response::InternalServerError) response | No
|
2024-11-16 11:14:51 +01:00
|
|
|
//! `form` | Enables the [`Form`](crate::extract::Form) extractor | No
|
|
|
|
|
//! `json-deserializer` | Enables the [`JsonDeserializer`](crate::extract::JsonDeserializer) extractor | No
|
|
|
|
|
//! `json-lines` | Enables the [`JsonLines`](crate::extract::JsonLines) extractor and response | No
|
|
|
|
|
//! `multipart` | Enables the [`Multipart`](crate::extract::Multipart) extractor | No
|
|
|
|
|
//! `protobuf` | Enables the [`Protobuf`](crate::protobuf::Protobuf) extractor and response | No
|
|
|
|
|
//! `query` | Enables the [`Query`](crate::extract::Query) extractor | No
|
2024-03-16 22:34:18 +01:00
|
|
|
//! `tracing` | Log rejections from built-in extractors | Yes
|
2024-11-16 11:14:51 +01:00
|
|
|
//! `typed-routing` | Enables the [`TypedPath`](crate::routing::TypedPath) routing utilities | No
|
|
|
|
|
//! `typed-header` | Enables the [`TypedHeader`] extractor and response | No
|
2024-12-04 20:33:07 +08:00
|
|
|
//! `FileStream` | Enables the [`FileStream`](crate::response::FileStream) response | No
|
2022-06-10 08:46:09 +02:00
|
|
|
//!
|
2021-11-17 21:00:32 +01:00
|
|
|
//! [`axum`]: https://crates.io/crates/axum
|
|
|
|
|
|
2022-02-18 14:13:56 +01:00
|
|
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
2021-11-17 21:00:32 +01:00
|
|
|
#![cfg_attr(test, allow(clippy::float_cmp))]
|
2023-04-14 22:26:56 +02:00
|
|
|
#![cfg_attr(not(test), warn(clippy::print_stdout, clippy::dbg_macro))]
|
2021-11-17 22:54:02 +01:00
|
|
|
|
2023-02-11 23:10:07 +01:00
|
|
|
#[allow(unused_extern_crates)]
|
|
|
|
|
extern crate self as axum_extra;
|
|
|
|
|
|
2022-06-08 11:02:42 +02:00
|
|
|
pub mod body;
|
2022-08-17 10:57:19 +02:00
|
|
|
pub mod either;
|
2021-11-25 11:14:31 +01:00
|
|
|
pub mod extract;
|
2022-08-10 12:09:08 +02:00
|
|
|
pub mod handler;
|
2023-02-12 00:11:21 +01:00
|
|
|
pub mod middleware;
|
2021-11-17 22:54:02 +01:00
|
|
|
pub mod response;
|
2021-11-17 23:31:43 +01:00
|
|
|
pub mod routing;
|
2022-02-18 14:13:56 +01:00
|
|
|
|
2022-06-20 20:49:18 +02:00
|
|
|
#[cfg(feature = "json-lines")]
|
|
|
|
|
pub mod json_lines;
|
|
|
|
|
|
2023-04-11 16:09:48 +02:00
|
|
|
#[cfg(feature = "typed-header")]
|
|
|
|
|
pub mod typed_header;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "typed-header")]
|
|
|
|
|
#[doc(no_inline)]
|
|
|
|
|
pub use headers;
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "typed-header")]
|
|
|
|
|
#[doc(inline)]
|
|
|
|
|
pub use typed_header::TypedHeader;
|
|
|
|
|
|
2022-08-10 17:14:42 +02:00
|
|
|
#[cfg(feature = "protobuf")]
|
|
|
|
|
pub mod protobuf;
|
|
|
|
|
|
2024-03-24 03:46:20 +09:00
|
|
|
/// _not_ public API
|
2022-02-18 14:13:56 +01:00
|
|
|
#[cfg(feature = "typed-routing")]
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
pub mod __private {
|
|
|
|
|
use percent_encoding::{AsciiSet, CONTROLS};
|
|
|
|
|
|
|
|
|
|
pub use percent_encoding::utf8_percent_encode;
|
|
|
|
|
|
|
|
|
|
// from https://github.com/servo/rust-url/blob/master/url/src/parser.rs
|
|
|
|
|
const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`');
|
|
|
|
|
const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}');
|
|
|
|
|
pub const PATH_SEGMENT: &AsciiSet = &PATH.add(b'/').add(b'%');
|
|
|
|
|
}
|
2022-04-03 18:29:37 +02:00
|
|
|
|
2023-04-09 14:23:13 +02:00
|
|
|
#[cfg(test)]
|
|
|
|
|
use axum_macros::__private_axum_test as test;
|
|
|
|
|
|
2022-04-03 18:29:37 +02:00
|
|
|
#[cfg(test)]
|
2024-03-24 03:46:20 +09:00
|
|
|
#[allow(unused_imports)]
|
2022-04-03 18:29:37 +02:00
|
|
|
pub(crate) mod test_helpers {
|
2023-03-22 23:42:14 +01:00
|
|
|
use axum::{extract::Request, response::Response, serve};
|
2022-04-03 18:29:37 +02:00
|
|
|
|
|
|
|
|
mod test_client {
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
include!(concat!(
|
|
|
|
|
env!("CARGO_MANIFEST_DIR"),
|
|
|
|
|
"/../axum/src/test_helpers/test_client.rs"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
pub(crate) use self::test_client::*;
|
|
|
|
|
}
|