mirror of
https://github.com/tokio-rs/axum.git
synced 2025-07-30 01:13:13 +02:00
Re-format trybuild tests (#3049)
This commit is contained in:
parent
f1c79a459b
commit
9ddb25f089
47 changed files with 97 additions and 154 deletions
axum-macros/tests
debug_handler
fail
multiple_request_consumers.rsmultiple_request_consumers.stderroutput_tuple_too_many.rsoutput_tuple_too_many.stderrreturning_request_parts.rsreturning_request_parts.stderrtoo_many_extractors.rswrong_order.rswrong_return_tuple.rswrong_return_tuple.stderr
pass
debug_middleware
from_ref/pass
from_request
fail
pass
container_parts.rsnamed.rsnamed_parts.rsnamed_via.rsnamed_via_parts.rsoverride_rejection_non_generic.rsoverride_rejection_non_generic_parts.rsoverride_rejection_with_via_on_struct.rsoverride_rejection_with_via_on_struct_parts.rsstate_cookie.rsstate_explicit.rsstate_explicit_parts.rsstate_field_explicit.rsstate_field_infer.rsstate_infer.rsstate_infer_multiple.rsstate_infer_parts.rsstate_via_infer.rsstate_with_rejection.rstuple_same_type_twice.rstuple_same_type_twice_parts.rs
typed_path
|
@ -1,5 +1,9 @@
|
|||
use axum::{
|
||||
body::Bytes,
|
||||
http::{Method, Uri},
|
||||
Json,
|
||||
};
|
||||
use axum_macros::debug_handler;
|
||||
use axum::{Json, body::Bytes, http::{Method, Uri}};
|
||||
|
||||
#[debug_handler]
|
||||
async fn one(_: Json<()>, _: String, _: Uri) {}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: Can't have two extractors that consume the request body. `Json<_>` and `String` both do that.
|
||||
--> tests/debug_handler/fail/multiple_request_consumers.rs:5:14
|
||||
--> tests/debug_handler/fail/multiple_request_consumers.rs:9:14
|
||||
|
|
||||
5 | async fn one(_: Json<()>, _: String, _: Uri) {}
|
||||
9 | async fn one(_: Json<()>, _: String, _: Uri) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: Can't have more than one extractor that consume the request body. `Json<_>`, `Bytes`, and `String` all do that.
|
||||
--> tests/debug_handler/fail/multiple_request_consumers.rs:8:14
|
||||
|
|
||||
8 | async fn two(_: Json<()>, _: Method, _: Bytes, _: Uri, _: String) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
--> tests/debug_handler/fail/multiple_request_consumers.rs:12:14
|
||||
|
|
||||
12 | async fn two(_: Json<()>, _: Method, _: Bytes, _: Uri, _: String) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use axum::response::AppendHeaders;
|
||||
|
||||
#[axum::debug_handler]
|
||||
async fn handler(
|
||||
) -> (
|
||||
async fn handler() -> (
|
||||
axum::http::StatusCode,
|
||||
AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
error: Cannot return tuples with more than 17 elements
|
||||
--> tests/debug_handler/fail/output_tuple_too_many.rs:5:3
|
||||
--> tests/debug_handler/fail/output_tuple_too_many.rs:4:20
|
||||
|
|
||||
5 | ) -> (
|
||||
| ___^
|
||||
6 | | axum::http::StatusCode,
|
||||
4 | async fn handler() -> (
|
||||
| ____________________^
|
||||
5 | | axum::http::StatusCode,
|
||||
6 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
7 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
8 | | AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
... |
|
||||
24 | | axum::http::StatusCode,
|
||||
25 | | ) {
|
||||
23 | | axum::http::StatusCode,
|
||||
24 | | ) {
|
||||
| |_^
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#[axum::debug_handler]
|
||||
async fn handler(
|
||||
) -> (
|
||||
async fn handler() -> (
|
||||
axum::http::request::Parts, // this should be response parts, not request parts
|
||||
axum::http::StatusCode,
|
||||
) {
|
||||
panic!()
|
||||
}
|
||||
|
||||
fn main(){}
|
||||
fn main() {}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error[E0308]: mismatched types
|
||||
--> tests/debug_handler/fail/returning_request_parts.rs:4:5
|
||||
--> tests/debug_handler/fail/returning_request_parts.rs:3:5
|
||||
|
|
||||
4 | axum::http::request::Parts, // this should be response parts, not request parts
|
||||
3 | axum::http::request::Parts, // this should be response parts, not request parts
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| expected `axum::http::response::Parts`, found `axum::http::request::Parts`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::debug_handler;
|
||||
use axum::http::Uri;
|
||||
use axum_macros::debug_handler;
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler(
|
||||
|
@ -20,6 +20,7 @@ async fn handler(
|
|||
_e15: Uri,
|
||||
_e16: Uri,
|
||||
_e17: Uri,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum::{http::Uri, Json};
|
||||
use axum_macros::debug_handler;
|
||||
use axum::{Json, http::Uri};
|
||||
|
||||
#[debug_handler]
|
||||
async fn one(_: Json<()>, _: Uri) {}
|
||||
|
|
|
@ -4,16 +4,13 @@
|
|||
async fn named_type() -> (
|
||||
axum::http::StatusCode,
|
||||
axum::Json<&'static str>,
|
||||
axum::response::AppendHeaders<[( axum::http::HeaderName,&'static str); 1]>,
|
||||
axum::response::AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
) {
|
||||
panic!()
|
||||
}
|
||||
|
||||
|
||||
struct CustomIntoResponse{
|
||||
|
||||
}
|
||||
impl axum::response::IntoResponse for CustomIntoResponse{
|
||||
struct CustomIntoResponse {}
|
||||
impl axum::response::IntoResponse for CustomIntoResponse {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
todo!()
|
||||
}
|
||||
|
@ -22,7 +19,7 @@ impl axum::response::IntoResponse for CustomIntoResponse{
|
|||
async fn custom_type() -> (
|
||||
axum::http::StatusCode,
|
||||
CustomIntoResponse,
|
||||
axum::response::AppendHeaders<[( axum::http::HeaderName,&'static str); 1]>,
|
||||
axum::response::AppendHeaders<[(axum::http::HeaderName, &'static str); 1]>,
|
||||
) {
|
||||
panic!()
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ error: `Json<_>` must be the last element in a response tuple
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not satisfied
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:24:5
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:21:5
|
||||
|
|
||||
24 | CustomIntoResponse,
|
||||
21 | CustomIntoResponse,
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `IntoResponseParts` is not implemented for `CustomIntoResponse`
|
||||
|
|
||||
= help: the following other types implement trait `IntoResponseParts`:
|
||||
|
@ -27,9 +27,9 @@ help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
|||
|
|
||||
|
||||
error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not satisfied
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:24:5
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:21:5
|
||||
|
|
||||
24 | CustomIntoResponse,
|
||||
21 | CustomIntoResponse,
|
||||
| ^^^^^^^^^^^^^^^^^^ the trait `IntoResponseParts` is not implemented for `CustomIntoResponse`
|
||||
|
|
||||
= help: the following other types implement trait `IntoResponseParts`:
|
||||
|
@ -43,7 +43,7 @@ error[E0277]: the trait bound `CustomIntoResponse: IntoResponseParts` is not sat
|
|||
(T1, T2, T3, T4, T5, T6, T7, T8)
|
||||
and $N others
|
||||
note: required by a bound in `__axum_macros_check_custom_type_into_response_parts_1_check`
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:24:5
|
||||
--> tests/debug_handler/fail/wrong_return_tuple.rs:21:5
|
||||
|
|
||||
24 | CustomIntoResponse,
|
||||
21 | CustomIntoResponse,
|
||||
| ^^^^^^^^^^^^^^^^^^ required by this bound in `__axum_macros_check_custom_type_into_response_parts_1_check`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::debug_handler;
|
||||
use axum::response::IntoResponse;
|
||||
use axum_macros::debug_handler;
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler() -> impl IntoResponse {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::debug_handler;
|
||||
use axum::extract::State;
|
||||
use axum_macros::debug_handler;
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler(_: State<AppState>) {}
|
||||
|
@ -8,22 +8,13 @@ async fn handler(_: State<AppState>) {}
|
|||
async fn handler_2(_: axum::extract::State<AppState>) {}
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler_3(
|
||||
_: axum::extract::State<AppState>,
|
||||
_: axum::extract::State<AppState>,
|
||||
) {}
|
||||
async fn handler_3(_: axum::extract::State<AppState>, _: axum::extract::State<AppState>) {}
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler_4(
|
||||
_: State<AppState>,
|
||||
_: State<AppState>,
|
||||
) {}
|
||||
async fn handler_4(_: State<AppState>, _: State<AppState>) {}
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler_5(
|
||||
_: axum::extract::State<AppState>,
|
||||
_: State<AppState>,
|
||||
) {}
|
||||
async fn handler_5(_: axum::extract::State<AppState>, _: State<AppState>) {}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::debug_handler;
|
||||
use axum::http::{Method, Uri};
|
||||
use axum_macros::debug_handler;
|
||||
|
||||
#[debug_handler]
|
||||
async fn handler(_one: Method, _two: Uri, _three: String) {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::debug_handler;
|
||||
use std::future::{Ready, ready};
|
||||
use std::future::{ready, Ready};
|
||||
|
||||
#[debug_handler]
|
||||
fn handler() -> Ready<()> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum::{extract::Request, extract::State};
|
||||
use axum_macros::debug_handler;
|
||||
use axum::{extract::State, extract::Request};
|
||||
|
||||
#[debug_handler(state = AppState)]
|
||||
async fn handler(_: State<AppState>, _: Request) {}
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
use axum::{
|
||||
extract::Request,
|
||||
response::Response,
|
||||
middleware::Next,
|
||||
debug_middleware,
|
||||
};
|
||||
use axum::{debug_middleware, extract::Request, middleware::Next, response::Response};
|
||||
|
||||
#[debug_middleware]
|
||||
async fn my_middleware(next: Next, request: Request) -> Response {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: `axum::middleware::Next` must the last argument
|
||||
--> tests/debug_middleware/fail/next_not_last.rs:9:24
|
||||
--> tests/debug_middleware/fail/next_not_last.rs:4:24
|
||||
|
|
||||
9 | async fn my_middleware(next: Next, request: Request) -> Response {
|
||||
4 | async fn my_middleware(next: Next, request: Request) -> Response {
|
||||
| ^^^^^^^^^^
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
use axum::{
|
||||
extract::Request,
|
||||
response::Response,
|
||||
middleware::Next,
|
||||
debug_middleware,
|
||||
};
|
||||
use axum::{debug_middleware, extract::Request, middleware::Next, response::Response};
|
||||
|
||||
#[debug_middleware]
|
||||
async fn my_middleware(request: Request, next: Next) -> Response {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
use axum::{Router, routing::get, extract::{State, FromRef}};
|
||||
use axum::{
|
||||
extract::{FromRef, State},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
|
||||
// This will implement `FromRef` for each field in the struct.
|
||||
#[derive(Clone, FromRef)]
|
||||
|
@ -14,7 +18,5 @@ fn main() {
|
|||
auth_token: Default::default(),
|
||||
};
|
||||
|
||||
let _: axum::Router = Router::new()
|
||||
.route("/", get(handler))
|
||||
.with_state(state);
|
||||
let _: axum::Router = Router::new().route("/", get(handler)).with_state(state);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ enum Extractor {
|
|||
Foo {
|
||||
#[from_request(via(axum::Extension))]
|
||||
foo: (),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::FromRequest;
|
||||
use axum::extract::State;
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum::{
|
||||
extract::{FromRequestParts, Extension},
|
||||
extract::{Extension, FromRequestParts},
|
||||
response::Response,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use axum::{
|
||||
extract::FromRequest,
|
||||
response::Response,
|
||||
};
|
||||
use axum::{extract::FromRequest, response::Response};
|
||||
use axum_extra::{
|
||||
TypedHeader,
|
||||
typed_header::TypedHeaderRejection,
|
||||
headers::{self, UserAgent},
|
||||
typed_header::TypedHeaderRejection,
|
||||
TypedHeader,
|
||||
};
|
||||
|
||||
#[derive(FromRequest)]
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use axum::{
|
||||
extract::FromRequestParts,
|
||||
response::Response,
|
||||
};
|
||||
use axum::{extract::FromRequestParts, response::Response};
|
||||
use axum_extra::{
|
||||
TypedHeader,
|
||||
typed_header::TypedHeaderRejection,
|
||||
headers::{self, UserAgent},
|
||||
typed_header::TypedHeaderRejection,
|
||||
TypedHeader,
|
||||
};
|
||||
|
||||
#[derive(FromRequestParts)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use axum::{
|
||||
response::Response,
|
||||
extract::{Extension, FromRequest},
|
||||
response::Response,
|
||||
};
|
||||
use axum_extra::{
|
||||
TypedHeader,
|
||||
typed_header::TypedHeaderRejection,
|
||||
headers::{self, UserAgent},
|
||||
typed_header::TypedHeaderRejection,
|
||||
TypedHeader,
|
||||
};
|
||||
|
||||
#[derive(FromRequest)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use axum::{
|
||||
response::Response,
|
||||
extract::{Extension, FromRequestParts},
|
||||
response::Response,
|
||||
};
|
||||
use axum_extra::{
|
||||
TypedHeader,
|
||||
typed_header::TypedHeaderRejection,
|
||||
headers::{self, UserAgent},
|
||||
typed_header::TypedHeaderRejection,
|
||||
TypedHeader,
|
||||
};
|
||||
|
||||
#[derive(FromRequestParts)]
|
||||
|
|
|
@ -5,8 +5,8 @@ use axum::{
|
|||
Router,
|
||||
};
|
||||
use axum_macros::FromRequest;
|
||||
use std::collections::HashMap;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let _: Router = Router::new().route("/", get(handler).post(handler_result));
|
||||
|
@ -17,10 +17,7 @@ async fn handler(_: MyJson) {}
|
|||
async fn handler_result(_: Result<MyJson, MyJsonRejection>) {}
|
||||
|
||||
#[derive(FromRequest, Deserialize)]
|
||||
#[from_request(
|
||||
via(axum::extract::Json),
|
||||
rejection(MyJsonRejection),
|
||||
)]
|
||||
#[from_request(via(axum::extract::Json), rejection(MyJsonRejection))]
|
||||
#[serde(transparent)]
|
||||
struct MyJson(HashMap<String, String>);
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ use axum::{
|
|||
Router,
|
||||
};
|
||||
use axum_macros::FromRequestParts;
|
||||
use std::collections::HashMap;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
let _: Router = Router::new().route("/", get(handler).post(handler_result));
|
||||
|
@ -17,10 +17,7 @@ async fn handler(_: MyQuery) {}
|
|||
async fn handler_result(_: Result<MyQuery, MyQueryRejection>) {}
|
||||
|
||||
#[derive(FromRequestParts, Deserialize)]
|
||||
#[from_request(
|
||||
via(axum::extract::Query),
|
||||
rejection(MyQueryRejection),
|
||||
)]
|
||||
#[from_request(via(axum::extract::Query), rejection(MyQueryRejection))]
|
||||
#[serde(transparent)]
|
||||
struct MyQuery(HashMap<String, String>);
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@ async fn handler(_: MyJson<Payload>) {}
|
|||
async fn handler_result(_: Result<MyJson<Payload>, MyJsonRejection>) {}
|
||||
|
||||
#[derive(FromRequest)]
|
||||
#[from_request(
|
||||
via(axum::Json),
|
||||
rejection(MyJsonRejection),
|
||||
)]
|
||||
#[from_request(via(axum::Json), rejection(MyJsonRejection))]
|
||||
struct MyJson<T>(T);
|
||||
|
||||
struct MyJsonRejection {}
|
||||
|
|
|
@ -19,10 +19,7 @@ async fn handler(_: MyQuery<Payload>) {}
|
|||
async fn handler_result(_: Result<MyQuery<Payload>, MyQueryRejection>) {}
|
||||
|
||||
#[derive(FromRequestParts)]
|
||||
#[from_request(
|
||||
via(axum::extract::Query),
|
||||
rejection(MyQueryRejection),
|
||||
)]
|
||||
#[from_request(via(axum::extract::Query), rejection(MyQueryRejection))]
|
||||
struct MyQuery<T>(T);
|
||||
|
||||
struct MyQueryRejection {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use axum_macros::FromRequest;
|
||||
use axum::extract::FromRef;
|
||||
use axum_extra::extract::cookie::{PrivateCookieJar, Key};
|
||||
use axum_extra::extract::cookie::{Key, PrivateCookieJar};
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
#[from_request(state(AppState))]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use axum_macros::FromRequest;
|
||||
use axum::{
|
||||
extract::{FromRef, State},
|
||||
Router,
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
fn main() {
|
||||
let _: axum::Router = Router::new()
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use axum_macros::FromRequestParts;
|
||||
use axum::{
|
||||
extract::{FromRef, State, Query},
|
||||
Router,
|
||||
extract::{FromRef, Query, State},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum_macros::FromRequestParts;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum::{
|
||||
extract::{State, FromRef},
|
||||
extract::{FromRef, State},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
use axum::{
|
||||
extract::State,
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum::{extract::State, routing::get, Router};
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::FromRequest;
|
||||
use axum::extract::State;
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::FromRequest;
|
||||
use axum::extract::State;
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_macros::FromRequestParts;
|
||||
use axum::extract::State;
|
||||
use axum_macros::FromRequestParts;
|
||||
|
||||
#[derive(FromRequestParts)]
|
||||
struct Extractor {
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
use axum::{
|
||||
extract::State,
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use axum::{extract::State, routing::get, Router};
|
||||
use axum_macros::FromRequest;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use std::convert::Infallible;
|
||||
use axum::{
|
||||
extract::State,
|
||||
response::{IntoResponse, Response},
|
||||
|
@ -6,6 +5,7 @@ use axum::{
|
|||
Router,
|
||||
};
|
||||
use axum_macros::FromRequest;
|
||||
use std::convert::Infallible;
|
||||
|
||||
fn main() {
|
||||
let _: axum::Router = Router::new()
|
||||
|
|
|
@ -3,10 +3,7 @@ use axum_macros::FromRequest;
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(FromRequest)]
|
||||
struct Extractor(
|
||||
Query<Payload>,
|
||||
axum::extract::Json<Payload>,
|
||||
);
|
||||
struct Extractor(Query<Payload>, axum::extract::Json<Payload>);
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Payload {}
|
||||
|
|
|
@ -3,10 +3,7 @@ use axum_macros::FromRequestParts;
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(FromRequestParts)]
|
||||
struct Extractor(
|
||||
Query<Payload>,
|
||||
axum::extract::Path<Payload>,
|
||||
);
|
||||
struct Extractor(Query<Payload>, axum::extract::Path<Payload>);
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Payload {}
|
||||
|
|
|
@ -5,5 +5,4 @@ use serde::Deserialize;
|
|||
#[typed_path("/users/{id}")]
|
||||
struct MyPath {}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_extra::routing::TypedPath;
|
||||
use axum::http::Uri;
|
||||
use axum_extra::routing::TypedPath;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(TypedPath, Deserialize)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use axum_extra::routing::{TypedPath, RouterExt};
|
||||
use axum::{extract::rejection::PathRejection, http::StatusCode};
|
||||
use axum_extra::routing::{RouterExt, TypedPath};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(TypedPath, Deserialize)]
|
||||
|
|
|
@ -5,8 +5,7 @@ use axum_extra::routing::TypedPath;
|
|||
struct MyPath;
|
||||
|
||||
fn main() {
|
||||
_ = axum::Router::<()>::new()
|
||||
.route("/", axum::routing::get(|_: MyPath| async {}));
|
||||
_ = axum::Router::<()>::new().route("/", axum::routing::get(|_: MyPath| async {}));
|
||||
|
||||
assert_eq!(MyPath::PATH, "/users");
|
||||
assert_eq!(format!("{}", MyPath), "/users");
|
||||
|
|
|
@ -22,11 +22,5 @@ fn main() {
|
|||
"/a%20b"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
format!(
|
||||
"{}",
|
||||
Unnamed("a b".to_string()),
|
||||
),
|
||||
"/a%20b"
|
||||
);
|
||||
assert_eq!(format!("{}", Unnamed("a b".to_string()),), "/a%20b");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue