* 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
* changelog
* bump versions
* reorder changelogs a bit
* Apply suggestions from code review
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* Expand fallback inheritance
* Reword tsr
* Mention `parse-body-based-on-content-type` example
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* 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 <jplatte+git@posteo.de>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* New release candidates
* Update axum/Cargo.toml
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* Don't allow extracting `MatchedPath` for nested paths
* misc clean up
* Update docs
* changelog
* Apply suggestions from code review
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* Add test for nested handler service
* change to `debug_assert`
* apply suggestions from review
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
* 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`
* Add RawForm extractor
* Change RawForm(String) to RawForm(Option<String>)
* Fix tests
* Use Bytes instead of Option<String> and add tests
* Add test for empty body
* Update CHANGELOG
* small docs tweaks
* changelog nit
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* 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
* Move RequestExt and RequestPartsExt into axum-core
* Add RequestExt::into_limited_body
… and use it for Bytes extraction.
* Add RequestExt::with_limited_body
… and use it for Multipart extraction.
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* add server feature and make tokio and hyper/server and tcp optional
* address review comments
* don't mention any specific runtimes in the example
* sort deps
* add `tokio` feature when adding `ws`
* don't always pull in tower feature that pulls in tokio io stuff
* remove usage of `tokio_cr`
* changelog
* depend on tokio version that supports wasm
* don't make it sound like tokio doesn't support wasm
* call out new default feature
Co-authored-by: Fisher Darling <fdarlingco@gmail.com>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Rename Fallback::Custom to Fallback::Service
* Allow Routers to inherit state
* Rename Router::{nest => nest_service} and add new nest method for Routers
* Fix lints
* Add basic tests for state inheritance
* Changelog
* 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
Previously, it was difficult to find out the path in the deep JSON tree at
which a deserialization error occurred. This patch makes an error message
to contain the errored path. In order to find out the path,
I added serde_path_to_error, a new optional dependency.
Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>