- **fixed:** Fix using incorrect path prefix when nesting `Router`s at `/` ([#691])
- **fixed:** Make `nest("", service)` work and mean the same as `nest("/", service)` ([#691])
- **fixed:** Replace response code `301` with `308` for trailing slash redirects. Also deprecates
`Redirect::found` (`302`) in favor of `Redirect::temporary` (`307`) or `Redirect::to` (`303`).
This is to prevent clients from changing non-`GET` requests to `GET` requests ([#682])
[#691]: https://github.com/tokio-rs/axum/pull/691
[#682]: https://github.com/tokio-rs/axum/pull/682
* Use 308 status instead of 301 when redirecting
For redirects resulting from requests to paths with a trailing slash,
use 308 instead of 301 to prevent non-GET requests (POST, PUT, etc) from
being changed to GET.
For example, (assuming a route for /path is defined)...
- Old behavior results in:
POST /path/ -> GET /path
- New behavior results in:
POST /path/ -> POST /path
Fixes#681
* Add deprecation notice to found()
Deprecates found() due to its use of HTTP 302
* rustfmt
* Use dedicated redirect method
Use Redirect::permanent instead of re-implementing its functionality
* Remove deprecated method from example
Replace usages of Redirect:found with Redirect::to and Redirect::temporary as appropriate
* Fix panic in oauth example
Previously the example would panic if a request was made without the
`Cookie` header. Now the user is redirected to the login page as
expected.
* Update CHANGELOG
* Revert pub TypedheaderRejection fields
* Fix clippy lint
* cargo fmt
* Fix CHANGELOG link
* Adhere to implicit line length limit
* Add some debug assertions
As discussed in Discord its probably worth having debug assertions for
these two cases, should we accidentally break them in the future.
* remove assertion in `OriginalUri`
In `Router::route`, the link to the "Routing to services and
backpressure" section on the crate documentation page directed to
<https://docs.rs/#routing-to-services-and-backpressure>. This change
makes it direct to the main crate documentation page.
* Simplify json content-type check
* Import HeaderMap from http instead of from headers
The headers crate is an optional dependency and its HeaderMap re-export
is `#[doc(hidden)]`.
* Use headers re-export in axum in examples
* Add `middleware::from_fn` for creating middleware from async fns
* More trait impls for `Next`
* Make `Next::run` consume `self`
* Use `.router_layer` in example, since middleware returns early
* Actually `Next` probably shouldn't impl `Clone` and `Service`
Has implications for backpressure and stuff
* Simplify `print-request-response` example
* Address review feedback
* add changelog link
* use 'crate::body::HttpBody' instead of 'http_body::Body'
* use 'crate::body::Bytes' instead of 'bytes::Bytes'
* rustfmt
* fix warning
* Update axum/src/routing/method_routing.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
* Update axum/src/routing/method_routing.rs
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
- Support checking `FromRequest` bounds for extractors whose request body is something else than
`axum::body::Body`. Use `#[debug_handler(body = YourBodyType)]` to use a different request body
type ([#595])
[#595]: https://github.com/tokio-rs/axum/pull/595