Commit Graph
100 Commits
Author SHA1 Message Date
David Pedersen aa2cbf6920 Add axum_extra::extract::Multipart (#1692) 2023-03-03 10:15:09 +01:00
David Pedersen 416a0568d3 Add special handling of FromRequest extractors not being the last arg (#1797) 2023-03-03 09:44:10 +01:00
David Pedersen 08bac36519 Release axum and axum-extra (#1788) 2023-02-27 09:41:11 +01:00
David Pedersen 279a8e2bf0 Add example showing how to run axum on hyper 1.0 (#1791) 2023-02-26 19:05:12 +01:00
David Pedersen 1dc4b44472 Use JsonRejection::{status, body_text} in customize extractor error example (#1790) 2023-02-25 15:02:02 +01:00
David Pedersen 27f05ad32e Remove SpaRouter (#1784) 2023-02-25 11:05:23 +01:00
David Pedersen f726f16b6d Update to tower-http 0.4 (#1783) 2023-02-24 20:51:30 +00:00
David PedersenandAllan 6a4825bb22 Rename ProtoBuf to Protobuf (#1763)
Co-authored-by: Allan <[email protected]>
2023-02-24 21:40:42 +01:00
David Pedersen 37478772bc Release axum (#1782) 2023-02-24 14:22:47 +01:00
David Pedersen 2cbaa63d9e Add KeepAlive::event (#1729) 2023-02-23 13:14:29 +00:00
David Pedersen 1e2567c39f Fix missing Allow when middleware are applied to MethodRouter (#1773) 2023-02-20 22:54:44 +01:00
David Pedersen 277be8f813 axum 0.6.7 (#1768) 2023-02-17 15:07:23 +01:00
David Pedersen bea84d2141 Add missing things back to changelog 2023-02-17 14:25:03 +01:00
David Pedersen 143c415955 Add MockConnectInfo (#1767) 2023-02-17 13:09:29 +01:00
David Pedersen cd86f7ec7a Use 422 Unprocessable Entity for Form deserialization errors, except GET and HEAD requests (#1683) 2023-02-17 09:59:02 +01:00
David Pedersen e6ff0281ae Try cargo public-api-crates on CI (#1761) 2023-02-16 22:41:41 +01:00
David Pedersen c18ff9dd63 Release axum, axum-extra, and axum-macros (#1750) 2023-02-12 12:40:42 +01:00
David Pedersen c454e37a1c Update to cookie 0.17 (#1747) 2023-02-12 08:26:37 +01:00
David Pedersen 37922ab840 Add option_layer (#1696) 2023-02-11 23:11:21 +00:00
David Pedersen 0ecf5eeb19 Support passing MethodRouter to Router::fallback (#1730) 2023-02-11 23:11:55 +01:00
David Pedersen b4204e223d Add TypedPath::with_query_params (#1744) 2023-02-11 22:10:07 +00:00
David Pedersen 93ecabf449 Release axum and axum-macros (#1743) 2023-02-11 22:32:16 +01:00
David Pedersen 827140f0d7 Document gotchas with impl IntoResponse (#1736) 2023-02-07 21:28:00 +00:00
David Pedersen 0a3b4b8e43 Ignore duplicate dependencies pulled in by windows-sys 2023-02-07 22:21:00 +01:00
David Pedersen 6e6aa8f39e Don't use impl IntoResponse in readme 2023-02-07 17:57:28 +01:00
David Pedersen 4a5dc4391c Release axum and axum-macros (#1721) 2023-01-24 13:31:33 +01:00
David Pedersen 47be78e0b3 Use map_while (#1720) 2023-01-24 12:49:36 +01:00
David Pedersen 6ff6b36293 Release axum and axum-core (#1716) 2023-01-20 23:51:19 +01:00
David Pedersen 5b07296001 Add RawPathParams (#1713) 2023-01-20 20:37:01 +00:00
David Pedersen 96b7d78a3f Document required tokio features for example (#1715) 2023-01-20 20:26:40 +00:00
David Pedersen 7a52161826 Implement Clone and Service for Next (#1712) 2023-01-20 21:19:01 +01:00
David Pedersen 8c081c20ab Remove accidentally committed dbg!s 2023-01-20 10:14:49 +01:00
David Pedersen 00d20eb007 Simpify parse-body-based-on-content-type example (#1697) 2023-01-14 18:39:09 +01:00
David Pedersen 1be25d9496 Add internal macro to make tests of nest easier to write (#1694) 2023-01-14 14:12:01 +00:00
David Pedersen 607a20dfac Support deserialize_any for Path (#1693) 2023-01-13 12:27:38 +00:00
David Pedersen 25a46fbe79 fixup changelog 2023-01-13 11:54:30 +01:00
David Pedersen e3aaeb3cb7 Release axum, axum-core, and axum-macros (#1688) 2023-01-09 13:54:49 +01:00
David Pedersen d11af167ca Replace actions-rs/toolchain@v1 with stable alternative (#1687) 2023-01-08 16:41:59 +01:00
David Pedersen 3d31bcb6fb Remove lingering async-graphql example file
It should have been deleted previously
2023-01-08 16:28:45 +01:00
David Pedersen be9a8c0380 Document breaking changes related to nest (#1684) 2023-01-07 19:06:59 +01:00
David PedersenandJonas Platte 1aa357c879 Misc documentation improvements (#1647)
Co-authored-by: Jonas Platte <[email protected]>
2023-01-07 14:07:54 +01:00
David Pedersen 7e13d69639 Add status and body_text methods to built-in rejections (#1612)
* Add `status` and `body_text` methods to built-in rejections

This should make it easier to customize a built-in rejection while
preserving either the status or body.

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

* changelog
2022-12-02 19:54:16 +01:00
David Pedersen ee3cb971f7 axum-extra v0.4.2 (#1609) 2022-12-02 10:55:11 +00:00
David Pedersen 7386e5d185 Bug fixes for RouterExt:{route_with_tsr, route_service_with_tsr} (#1608)
* Bug fixes for `RouterExt:{route_with_tsr, route_service_with_tsr}`

* changelog link
2022-12-02 11:42:49 +01:00
David Pedersen 2121979a48 axum-extra - v0.4.1 (#1590) 2022-11-29 10:57:25 +01:00
David Pedersen c7985b7858 Fix wrong From impl for Resource (#1589)
Really not sure how this got past the tests.
2022-11-29 09:35:26 +00:00
David Pedersen 87a80ec47b axum v0.6.1 (#1588) 2022-11-29 08:43:18 +00:00
David Pedersen eb2e933054 Expand the docs for Router::with_state (#1580) 2022-11-27 01:01:59 +01:00
David Pedersen b984fec572 Remove notice about breaking changes from readme 2022-11-25 22:42:35 +01:00
David PedersenandJonas Platte 1b6780cf6c axum 0.6 and friends 🎉 (#1570)
* changelog

* bump versions

* reorder changelogs a bit

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

* Expand fallback inheritance

* Reword tsr

* Mention `parse-body-based-on-content-type` example

Co-authored-by: Jonas Platte <[email protected]>
2022-11-25 12:29:58 +00:00
David Pedersen 0b26411f39 Change Router::with_state and impl Service for Router<()> (#1552)
* Implement `Service` for `Router<(), B>`

* wip

* wip

* fix some tests

* fix examples

* fix doc tests

* clean up docs

* changelog

* fix

* also call `with_state` when converting `MethodRouter` into a `MakeService`

* suggestions from review
2022-11-24 14:43:10 +00:00
David Pedersen b816ac7cdf Add RouterService::{layer, route_layer} (#1550)
* Add `RouterService::{layer, route_layer}`

Figure we might as well have these.

* changelog
2022-11-19 21:51:55 +00:00
David Pedersen 99c0224a7c axum-extra 0.4.0-rc.3 (#1545)
* axum-extra 0.4.0-rc.3

Needs a new release because it uses the old state inheritance whic is
removed in the latest rc.

* fix
2022-11-19 13:02:11 +01:00
David Pedersen 2e3000f1a3 Fix typo 2022-11-18 18:36:49 +01:00
David Pedersen 37b9b3df48 Remove duplicate changelog entry 2022-11-18 17:59:05 +01:00
David Pedersen 878ae73e6d New release candidates (#1541) 2022-11-18 17:29:47 +01:00
David Pedersen 468985373a Add example of how to test WebSockets (#1535) 2022-11-18 15:40:21 +01:00
David Pedersen 7d58d49817 Add #[from_ref(skip)] (#1537)
For skipping individual fields.
2022-11-18 12:05:10 +01:00
David Pedersen 64960bb19c Type safe state inheritance (#1532)
* Make state type safe

* fix examples

* remove unnecessary `#[track_caller]`s

* Router::into_service -> Router::with_state

* fixup docs

* macro docs

* add missing docs

* fix examples

* format

* changelog

* Update trybuild tests

* Make sure fallbacks are still inherited for opaque services (#1540)

* Document nesting routers with different state

* fix leftover conflicts
2022-11-18 11:02:58 +00:00
David PedersenandJonas Platte ba8e9c1b21 Add on_failed_upgrade callback to WebSocketUpgrade (#1539)
* Add `on_failed_upgrade` callback to `WebSocket`

Previously if upgrading a connection to a WebSocket connection failed
the background task would panic. There was no way to customize that so
users that might wanna report the error was out of luck.

Panicking also wasn't great because users might abort on panics which
would bring down the server.

* changelog

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
2022-11-18 10:53:04 +00:00
David Pedersen 7090649377 Add fallback inheritance for nested routers (#1521)
* fallback inheritance

* cleanup

* changelog
2022-11-18 10:25:04 +00:00
David Pedersen 2e8a7e51a1 Fix Handler::with_state not working if request body was changed via layer (#1536)
Previously

```rust
handler.layer(RequestBodyLimitLayer::new(...)).with_state(...)
```

didn't work because we required the same request body all the way
through.
2022-11-18 11:00:52 +01:00
David Pedersen b1f894a500 Fix unused import if compiling with default features 2022-11-18 00:22:11 +01:00
David Pedersen 74bbe80f8a axum 0.6.0-rc.4 (#1518) 2022-11-09 13:49:47 +01:00
David Pedersen 028cac4a72 Fix compile error in release mode (#1517) 2022-11-09 13:36:10 +01:00
David Pedersen 1d6a96ee20 Remove references to *_with_state_arc functions from changelog
They were removed again before being released.
2022-11-09 09:27:37 +01:00
David Pedersen e53c85c496 Minor changelog fixes 2022-11-09 09:20:09 +01:00
David PedersenandJonas Platte e39d053d2f New release candidates (#1514)
* New release candidates

* Update axum/Cargo.toml

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
2022-11-09 09:01:47 +01:00
David Pedersen 9c804d506e Update changelog for axum-extra 2022-11-08 21:45:05 +01:00
David PedersenandJonas Platte 0e3f9d0938 Don't allow extracting MatchedPath in middleware for nested routes (#1462)
* Don't allow extracting `MatchedPath` for nested paths

* misc clean up

* Update docs

* changelog

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

* Add test for nested handler service

* change to `debug_assert`

* apply suggestions from review

Co-authored-by: Jonas Platte <[email protected]>
2022-11-08 20:43:19 +00:00
David Pedersen e0ef641e5f Rework Form and Query rejections (#1496)
* Change `FailedToDeserializeQueryString` rejection for `Form`

Its now called `FailedToDeserializeForm`.

* changelog

* Make dedicate rejection type for axum-extra's `Form`

* update trybuild test

* Make dedicate rejection type for axum-extra's `Query`
2022-11-08 20:31:06 +00:00
David Pedersen a27bd2c6a2 Update trybuild tests for Rust 1.65.0 (#1509) 2022-11-04 09:07:57 +01:00
David PedersenandJonas Platte b59c7a8c84 Add example for Router::inherit_state (#1492)
* Add example for `Router::inherit_state`

* clarification

* Update axum/src/routing/mod.rs

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
2022-10-20 19:19:05 +00:00
David Pedersen 958d360ac4 Generalize AppendHeaders to accept any impl IntoIterator (#1495)
* Generalize `AppendHeaders` to accept any `impl IntoIterator`

* changelog
2022-10-20 21:05:04 +02:00
David Pedersen 4979b4c9b6 Implement Form in terms of RawForm 2022-10-20 20:55:11 +02:00
David Pedersen 7caa4a3a47 Link to fork of realworld-axum-sqlx 2022-10-14 23:42:58 +02:00
David Pedersen 199a7a66b8 Expand static file serving example (#1471) 2022-10-11 07:42:48 +00:00
David Pedersen 9c0a89cd09 Add #[derive(FromRef)] (#1430)
* add `#[derive(FromRef)]`

* tests

* don't support skipping fields

probably wouldn't work at all since the whole state likely needs `Clone`

* UI tests

* changelog

* changelog link

* revert hello-world example, used for testing

* Re-export `#[derive(FromRef)]`

* Don't need to return `Result`

* use `collect` instead of quoting the iterator

* Mention it in axum's changelog
2022-10-10 18:40:14 +00:00
David Pedersen 1681ecf438 Copy changelogs from 0.5.x branch 2022-10-10 20:23:11 +02:00
David Pedersen d7ba0b1d72 Relax bounds for FromExtractor (#1469)
Fixes #1467

We didn't actually use the bounds. I guess they were left over from a
previous version.
2022-10-10 16:39:16 +00:00
David Pedersen 70833b9f4f Document differences between DefaultBodyLimit and RequestBodyLimit (#1461)
* Document differences between `DefaultBodyLimit` and `RequestBodyLimit`

* fix grammar

* fix accidental force push
2022-10-10 17:43:05 +02:00
David Pedersen 7420721f4d Document RouterService (#1465)
Not sure what else there is to say :P

Fixes https://github.com/tokio-rs/axum/issues/1401
2022-10-10 00:23:11 +02:00
David Pedersen b607ad5823 Improve map_response docs (#1464)
* Document when extractors run

* Document returning `impl IntoResponse`
2022-10-09 23:33:22 +02:00
David Pedersen f9dc96fdce Don't internally Arc the state (#1460) 2022-10-09 20:55:28 +00:00
David Pedersen a57bd9a118 Move changelog item to "unreleased" 2022-10-04 14:25:31 +02:00
David Pedersen 04ef2f1bc0 Add map_response and friends (#1414)
* Add `map_response` and friends

* changelog
2022-09-25 16:21:30 +02:00
David Pedersen 0e4a894c16 Fix formatting of one more macro 2022-09-25 15:26:36 +02:00
David Pedersen bf341fd034 Refactor all_the_tuples! macros (#1413) 2022-09-25 15:22:40 +02:00
David Pedersen 8dd9c8d286 Add missing changelog PR links 2022-09-25 14:41:15 +02:00
David PedersenandJonas Platte 2077d50021 Add map_request and friends (#1408)
* Add `map_request` and friends

* finish it

* changelog ref

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

* address review feedback

* Apply suggestions from code review

Co-authored-by: Jonas Platte <[email protected]>

Co-authored-by: Jonas Platte <[email protected]>
2022-09-25 11:44:10 +00:00
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
David Pedersen 611c50ec8b Add middleware::from_extractor_with_state (#1396)
Fixes https://github.com/tokio-rs/axum/issues/1373
2022-09-20 10:13:06 +02:00
David Pedersen 112f5354ab Add example showing how to return anyhow::Errors (#1398) 2022-09-19 20:42:08 +00:00
David Pedersen de9909d955 Add DefaultBodyLimit::max to change the body size limit (#1397) 2022-09-19 22:41:54 +02:00
David Pedersen c93d7c324e Fix typo in docs 2022-09-18 22:24:11 +02:00
David Pedersen 21876fcc64 Clarify Clone requirements for using State (#1388) 2022-09-18 22:22:47 +02:00
David Pedersen c81549d95b Support streaming/chunked requests in ContentLengthLimit (#1389)
* Support streaming/chunked requests in `ContentLengthLimit`

* changelog
2022-09-18 20:21:38 +00:00
David Pedersen 8e52c5246f Use 400 Bad Request for FailedToDeserializeQueryString rejections (#1387)
* Use `400 Bad Request` for `FailedToDeserializeQueryString` rejections

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

From [the spec] about `422 Unprocessable Entity`:

> For example, this error condition may occur if an XML request body
> contains well-formed (i.e., syntactically correct), but semantically
> erroneous, XML instructions.

I understand this to mean that query params shouldn't use 422 because
that is about the request body.

So this changes `FailedToDeserializeQueryString` from `422 Unprocessable
Entity` to `400 Bad Request`.

[the spec]: https://datatracker.ietf.org/doc/html/rfc4918#section-11.2

* changelog
2022-09-18 21:32:47 +02:00
David Pedersen 2abda4de88 Port other proc-macros to new attribute parsing (#1372) 2022-09-12 21:26:10 +02:00
David Pedersen 8da69a98fc Refactor proc-macro attribute parsing (#1369)
* Refactor proc-macro attribute parsing

* Remove `#[allow(warnings)]` which was accidentally committed

* Change span for "cannot use `rejection` without `via`" error for enums

* fix test
2022-09-12 20:10:58 +02:00