axum/axum-macros/tests/from_request/pass
David Pedersen c3f3db79ec
Support State with #[derive(FromRequest[Parts])] (#1391)
* Support `State` with `#[derive(FromRequest[Parts])]`

Fixes https://github.com/tokio-rs/axum/issues/1314

This makes it possible to extract things via `State` in
`#[derive(FromRequet)]`:

```rust
struct Foo {
    state: State<AppState>,
}
```

The state can also be inferred in a lot of cases so you only need to
write:

```rust
struct Foo {
    // since we're using `State<AppState>` we know the state has to be
    // `AppState`
    state: State<AppState>,
}
```

Same for

```rust
struct Foo {
    #[from_request(via(State))]
    state: AppState,
}
```

And

```rust
struct AppState {}
```

I think I've covered all the edge cases but there are (unsurprisingly) a
few.

* make sure things can be combined with other extractors

* main functions in ui tests don't need to be async

* Add test for multiple identicaly state types

* Add failing test for multiple states
2022-09-23 23:50:50 +02:00
..
container.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
container_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
empty_named.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
empty_named_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
empty_tuple.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
empty_tuple_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
enum_via.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
enum_via_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
named.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
named_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
named_via.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
named_via_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
override_rejection.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
override_rejection_non_generic.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
override_rejection_non_generic_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
override_rejection_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
override_rejection_with_via_on_enum.rs Support using a different rejection for #[derive(FromRequest)] (#1256) 2022-08-12 16:05:27 +00:00
override_rejection_with_via_on_enum_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
override_rejection_with_via_on_struct.rs Support using a different rejection for #[derive(FromRequest)] (#1256) 2022-08-12 16:05:27 +00:00
override_rejection_with_via_on_struct_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
state_cookie.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_enum_via.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_enum_via_parts.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_explicit.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_explicit_parts.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_field_explicit.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_field_infer.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_infer.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_infer_multiple.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_infer_parts.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_via.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_via_infer.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_via_parts.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
state_with_rejection.rs Support State with #[derive(FromRequest[Parts])] (#1391) 2022-09-23 23:50:50 +02:00
tuple.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
tuple_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
tuple_same_type_twice.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
tuple_same_type_twice_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
tuple_same_type_twice_via.rs Only allow last extractor to mutate the request (#1272) 2022-08-22 12:23:20 +02:00
tuple_same_type_twice_via_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
tuple_via.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
tuple_via_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00
unit.rs Add type safe state extractor (#1155) 2022-08-17 15:13:31 +00:00
unit_parts.rs Add #[derive(FromRequestParts)] (#1305) 2022-08-23 19:14:02 +00:00