1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
|
Description: break cyclic dependency
Author: Jonas Smedegaard <dr@jones.dk>
Bug-Debian: https://bugs.debian.org/1094199
Forwarded: not-needed
Last-Update: 2025-02-22
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/axum-core/Cargo.toml
+++ b/axum-core/Cargo.toml
@@ -35,8 +35,6 @@
tracing = { version = "0.1.37", default-features = false, optional = true }
[dev-dependencies]
-axum = { path = "../axum", features = ["__private"] }
-axum-extra = { path = "../axum-extra", features = ["typed-header"] }
axum-macros = { path = "../axum-macros", features = ["__private"] }
hyper = "1.0.0"
tokio = { version = "1.25.0", features = ["macros"] }
--- a/axum-core/src/ext_traits/request.rs
+++ b/axum-core/src/ext_traits/request.rs
@@ -18,7 +18,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// extract::{Request, FromRequest},
/// body::Body,
@@ -79,7 +79,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// body::Body,
/// extract::{Request, FromRef, FromRequest},
@@ -133,7 +133,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// extract::{Path, Request, FromRequest},
/// response::{IntoResponse, Response},
@@ -185,7 +185,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// extract::{Request, FromRef, FromRequest, FromRequestParts},
/// http::request::Parts,
@@ -331,99 +331,3 @@
self.with_limited_body().into_body()
}
}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use crate::{
- ext_traits::tests::{RequiresState, State},
- extract::FromRef,
- };
- use http::Method;
-
- #[tokio::test]
- async fn extract_without_state() {
- let req = Request::new(Body::empty());
-
- let method: Method = req.extract().await.unwrap();
-
- assert_eq!(method, Method::GET);
- }
-
- #[tokio::test]
- async fn extract_body_without_state() {
- let req = Request::new(Body::from("foobar"));
-
- let body: String = req.extract().await.unwrap();
-
- assert_eq!(body, "foobar");
- }
-
- #[tokio::test]
- async fn extract_with_state() {
- let req = Request::new(Body::empty());
-
- let state = "state".to_owned();
-
- let State(extracted_state): State<String> = req.extract_with_state(&state).await.unwrap();
-
- assert_eq!(extracted_state, state);
- }
-
- #[tokio::test]
- async fn extract_parts_without_state() {
- let mut req = Request::builder()
- .header("x-foo", "foo")
- .body(Body::empty())
- .unwrap();
-
- let method: Method = req.extract_parts().await.unwrap();
-
- assert_eq!(method, Method::GET);
- assert_eq!(req.headers()["x-foo"], "foo");
- }
-
- #[tokio::test]
- async fn extract_parts_with_state() {
- let mut req = Request::builder()
- .header("x-foo", "foo")
- .body(Body::empty())
- .unwrap();
-
- let state = "state".to_owned();
-
- let State(extracted_state): State<String> =
- req.extract_parts_with_state(&state).await.unwrap();
-
- assert_eq!(extracted_state, state);
- assert_eq!(req.headers()["x-foo"], "foo");
- }
-
- // this stuff just needs to compile
- #[allow(dead_code)]
- struct WorksForCustomExtractor {
- method: Method,
- from_state: String,
- body: String,
- }
-
- impl<S> FromRequest<S> for WorksForCustomExtractor
- where
- S: Send + Sync,
- String: FromRef<S> + FromRequest<()>,
- {
- type Rejection = <String as FromRequest<()>>::Rejection;
-
- async fn from_request(mut req: Request, state: &S) -> Result<Self, Self::Rejection> {
- let RequiresState(from_state) = req.extract_parts_with_state(state).await.unwrap();
- let method = req.extract_parts().await.unwrap();
- let body = req.extract().await?;
-
- Ok(Self {
- method,
- from_state,
- body,
- })
- }
- }
-}
--- a/axum-core/src/ext_traits/request_parts.rs
+++ b/axum-core/src/ext_traits/request_parts.rs
@@ -15,7 +15,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// extract::{Query, Path, FromRequestParts},
/// response::{Response, IntoResponse},
@@ -62,7 +62,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// extract::{FromRef, FromRequestParts},
/// response::{Response, IntoResponse},
@@ -133,60 +133,3 @@
E::from_request_parts(self, state)
}
}
-
-#[cfg(test)]
-mod tests {
- use std::convert::Infallible;
-
- use super::*;
- use crate::{
- ext_traits::tests::{RequiresState, State},
- extract::FromRef,
- };
- use http::{Method, Request};
-
- #[tokio::test]
- async fn extract_without_state() {
- let (mut parts, _) = Request::new(()).into_parts();
-
- let method: Method = parts.extract().await.unwrap();
-
- assert_eq!(method, Method::GET);
- }
-
- #[tokio::test]
- async fn extract_with_state() {
- let (mut parts, _) = Request::new(()).into_parts();
-
- let state = "state".to_owned();
-
- let State(extracted_state): State<String> = parts
- .extract_with_state::<State<String>, String>(&state)
- .await
- .unwrap();
-
- assert_eq!(extracted_state, state);
- }
-
- // this stuff just needs to compile
- #[allow(dead_code)]
- struct WorksForCustomExtractor {
- method: Method,
- from_state: String,
- }
-
- impl<S> FromRequestParts<S> for WorksForCustomExtractor
- where
- S: Send + Sync,
- String: FromRef<S>,
- {
- type Rejection = Infallible;
-
- async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
- let RequiresState(from_state) = parts.extract_with_state(state).await?;
- let method = parts.extract().await?;
-
- Ok(Self { method, from_state })
- }
- }
-}
--- a/axum-core/src/extract/default_body_limit.rs
+++ b/axum-core/src/extract/default_body_limit.rs
@@ -24,7 +24,7 @@
///
/// # Example
///
-/// ```
+/// ```ignore
/// use axum::{
/// Router,
/// routing::post,
@@ -48,7 +48,7 @@
/// `DefaultBodyLimit` can also be selectively applied to have different limits for different
/// routes:
///
-/// ```
+/// ```ignore
/// use axum::{
/// Router,
/// routing::post,
@@ -95,7 +95,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// Router,
/// routing::get,
@@ -129,7 +129,7 @@
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use axum::{
/// Router,
/// routing::get,
--- a/axum-core/src/response/append_headers.rs
+++ b/axum-core/src/response/append_headers.rs
@@ -7,7 +7,7 @@
/// Returning something like `[("content-type", "foo=bar")]` from a handler will override any
/// existing `content-type` headers. If instead you want to append headers, use `AppendHeaders`:
///
-/// ```rust
+/// ```ignore
/// use axum::{
/// response::{AppendHeaders, IntoResponse},
/// http::header::SET_COOKIE,
--- a/axum-core/src/response/into_response.rs
+++ b/axum-core/src/response/into_response.rs
@@ -26,7 +26,7 @@
/// However it might be necessary if you have a custom error type that you want
/// to return from handlers:
///
-/// ```rust
+/// ```ignore
/// use axum::{
/// Router,
/// body::{self, Bytes},
@@ -64,7 +64,7 @@
/// Or if you have a custom body type you'll also need to implement
/// `IntoResponse` for it:
///
-/// ```rust
+/// ```ignore
/// use axum::{
/// body,
/// routing::get,
--- a/axum-core/src/response/into_response_parts.rs
+++ b/axum-core/src/response/into_response_parts.rs
@@ -9,7 +9,7 @@
///
/// # Example
///
-/// ```rust
+/// ```ignore
/// use axum::{
/// response::{ResponseParts, IntoResponse, IntoResponseParts, Response},
/// http::{StatusCode, header::{HeaderName, HeaderValue}},
--- a/axum-core/src/response/mod.rs
+++ b/axum-core/src/response/mod.rs
@@ -28,7 +28,7 @@
///
/// # Example
///
-/// ```
+/// ```ignore
/// use axum::{
/// response::{IntoResponse, Response},
/// http::StatusCode,
@@ -80,7 +80,7 @@
///
/// Since `axum::response::Result` has a default error type you only have to specify the `Ok` type:
///
-/// ```
+/// ```ignore
/// use axum::{
/// response::{IntoResponse, Response, Result},
/// http::StatusCode,
--- a/axum-macros/Cargo.toml
+++ b/axum-macros/Cargo.toml
@@ -1,4 +1,5 @@
[package]
+exclude = ["tests/*"]
categories = ["asynchronous", "network-programming", "web-programming"]
description = "Macros for axum"
edition = "2021"
@@ -29,8 +30,6 @@
] }
[dev-dependencies]
-axum = { path = "../axum", features = ["macros"] }
-axum-extra = { path = "../axum-extra", features = ["typed-routing", "cookie-private", "typed-header"] }
rustversion = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
--- a/axum-macros/src/lib.rs
+++ b/axum-macros/src/lib.rs
@@ -32,7 +32,7 @@
///
/// By default `#[derive(FromRequest)]` will call `FromRequest::from_request` for each field:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::{
/// extract::Extension,
@@ -62,7 +62,7 @@
///
/// Note that only the last field can consume the request body. Therefore this doesn't compile:
///
-/// ```compile_fail
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::body::Bytes;
///
@@ -80,7 +80,7 @@
/// You can use `#[from_request(via(...))]` to extract a field via another extractor, meaning the
/// field itself doesn't need to implement `FromRequest`:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::{
/// extract::Extension,
@@ -126,7 +126,7 @@
///
/// `#[from_request(via(...))]` supports `Option<_>` and `Result<_, _>` to make fields optional:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum_extra::{
/// TypedHeader,
@@ -153,7 +153,7 @@
/// By default [`axum::response::Response`] will be used as the rejection. You can also use your own
/// rejection type with `#[from_request(rejection(YourType))]`:
///
-/// ```
+/// ```ignore
/// use axum::{
/// extract::{
/// rejection::{ExtensionRejection, StringRejection},
@@ -201,7 +201,7 @@
/// If the extraction can be done only for a concrete state, that type can be specified with
/// `#[from_request(state(YourState))]`:
///
-/// ```
+/// ```ignore
/// use axum::extract::{FromRequest, FromRequestParts};
///
/// #[derive(Clone)]
@@ -231,7 +231,7 @@
///
/// This is not needed for a `State<T>` as the type is inferred in that case.
///
-/// ```
+/// ```ignore
/// use axum::extract::{FromRequest, FromRequestParts, State};
///
/// #[derive(Clone)]
@@ -249,7 +249,7 @@
/// By using `#[from_request(via(...))]` on the container you can extract the whole type at once,
/// instead of each field individually:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::extract::Extension;
///
@@ -268,7 +268,7 @@
///
/// You can use a different rejection type with `#[from_request(rejection(YourType))]`:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::{
/// extract::{Extension, rejection::ExtensionRejection},
@@ -315,7 +315,7 @@
///
/// This allows you to wrap other extractors and easily customize the rejection:
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequest;
/// use axum::{
/// extract::{Extension, rejection::JsonRejection},
@@ -384,7 +384,7 @@
///
/// # Example
///
-/// ```
+/// ```ignore
/// use axum_macros::FromRequestParts;
/// use axum::{
/// extract::Query,
@@ -430,7 +430,7 @@
///
/// While using [`axum`], you can get long error messages for simple mistakes. For example:
///
-/// ```compile_fail
+/// ```ignore
/// use axum::{routing::get, Router};
///
/// #[tokio::main]
@@ -449,7 +449,7 @@
/// You will get a long error message about function not implementing [`Handler`] trait. But why
/// does this function not implement it? To figure it out, the [`debug_handler`] macro can be used.
///
-/// ```compile_fail
+/// ```ignore
/// # use axum::{routing::get, Router};
/// # use axum_macros::debug_handler;
/// #
@@ -477,7 +477,7 @@
///
/// As the error message says, handler function needs to be async.
///
-/// ```no_run
+/// ```ignore
/// use axum::{routing::get, Router, debug_handler};
///
/// #[tokio::main]
@@ -499,7 +499,7 @@
/// By default `#[debug_handler]` assumes your state type is `()` unless your handler has a
/// [`axum::extract::State`] argument:
///
-/// ```
+/// ```ignore
/// use axum::{debug_handler, extract::State};
///
/// #[debug_handler]
@@ -515,7 +515,7 @@
/// If your handler takes multiple [`axum::extract::State`] arguments or you need to otherwise
/// customize the state type you can set it with `#[debug_handler(state = ...)]`:
///
-/// ```
+/// ```ignore
/// use axum::{debug_handler, extract::{State, FromRef}};
///
/// #[debug_handler(state = AppState)]
@@ -590,7 +590,7 @@
///
/// # Example
///
-/// ```no_run
+/// ```ignore
/// use axum::{
/// routing::get,
/// extract::Request,
@@ -669,7 +669,7 @@
///
/// # Example
///
-/// ```
+/// ```ignore
/// use axum::{
/// Router,
/// routing::get,
--- a/axum/Cargo.toml
+++ b/axum/Cargo.toml
@@ -123,7 +123,6 @@
[dev-dependencies]
anyhow = "1.0"
-axum-extra = { path = "../axum-extra", features = ["typed-header"] }
axum-macros = { path = "../axum-macros", features = ["__private"] }
hyper = { version = "1.1.0", features = ["client"] }
quickcheck = "1.0"
--- a/axum-core/src/extract/request_parts.rs
+++ b/axum-core/src/extract/request_parts.rs
@@ -166,28 +166,3 @@
Ok(req.into_body())
}
}
-
-#[cfg(test)]
-mod tests {
- use axum::{extract::Extension, routing::get, test_helpers::*, Router};
- use http::{Method, StatusCode};
-
- #[crate::test]
- async fn extract_request_parts() {
- #[derive(Clone)]
- struct Ext;
-
- async fn handler(parts: http::request::Parts) {
- assert_eq!(parts.method, Method::GET);
- assert_eq!(parts.uri, "/");
- assert_eq!(parts.version, http::Version::HTTP_11);
- assert_eq!(parts.headers["x-foo"], "123");
- parts.extensions.get::<Ext>().unwrap();
- }
-
- let client = TestClient::new(Router::new().route("/", get(handler)).layer(Extension(Ext)));
-
- let res = client.get("/").header("x-foo", "123").await;
- assert_eq!(res.status(), StatusCode::OK);
- }
-}
--- a/axum/src/docs/extract.md
+++ b/axum/src/docs/extract.md
@@ -246,7 +246,7 @@
header you're trying to extract is not part of the request, but if the header
is present and fails to parse, the request is rejected.
-```rust,no_run
+```rust,ignore
use axum::{routing::post, Router};
use axum_extra::{headers::UserAgent, TypedHeader};
use serde_json::Value;
--- a/axum/src/extract/mod.rs
+++ b/axum/src/extract/mod.rs
@@ -95,20 +95,3 @@
content_type.starts_with(expected_content_type.as_ref())
}
-
-#[cfg(test)]
-mod tests {
- use crate::{routing::get, test_helpers::*, Router};
-
- #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
- #[crate::test]
- async fn consume_body() {
- let app = Router::new().route("/", get(|body: String| async { body }));
-
- let client = TestClient::new(app);
- let res = client.get("/").body("foo").await;
- let body = res.text().await;
-
- assert_eq!(body, "foo");
- }
-}
|