axum - v0.5.0
-
added: Document sharing state between handler and middleware (#783)
-
added:
Extension<_>can now be used in tuples for building responses, and will set an
extension on the response (#797) -
added:
extract::Hostfor extracting the hostname of a request (#827) -
added: Add
IntoResponsePartstrait which allows defining custom response
types for adding headers or extensions to responses (#797) -
added:
TypedHeaderimplements the newIntoResponsePartstrait so they
can be returned from handlers as parts of a response (#797) -
changed:
Router::mergenow acceptsInto<Router>(#819) -
breaking:
sse::Eventnow accepts types implementingAsRef<str>instead ofInto<String>
as field values. -
breaking:
sse::Eventnow panics if a setter method is called twice instead of silently
overwriting old values. -
breaking: Require
Output = ()onWebSocketStream::on_upgrade(#644) -
breaking: Make
TypedHeaderRejectionReason#[non_exhaustive](#665) -
breaking: Using
HeaderMapas an extractor will no longer remove the headers and thus
they'll still be accessible to other extractors, such asaxum::extract::Json. Instead
HeaderMapwill clone the headers. You should prefer to useTypedHeaderto extract only the
headers you need (#698)This includes these breaking changes:
RequestParts::take_headershas been removed.RequestParts::headersreturns&HeaderMap.RequestParts::headers_mutreturns&mut HeaderMap.HeadersAlreadyExtractedhas been removed.- The
HeadersAlreadyExtractedvariant has been removed from these rejections:RequestAlreadyExtractedRequestPartsAlreadyExtractedJsonRejectionFormRejectionContentLengthLimitRejectionWebSocketUpgradeRejection
<HeaderMap as FromRequest<_>>::Rejectionhas been changed tostd::convert::Infallible.
-
breaking:
axum::http::Extensionsis no longer an extractor (ie it
doesn't implementFromRequest). Theaxum::extract::Extensionextractor is
not impacted by this and works the same. This change makes it harder to
accidentally remove all extensions which would result in confusing errors
elsewhere (#699)
This includes these breaking changes:RequestParts::take_extensionshas been removed.RequestParts::extensionsreturns&Extensions.RequestParts::extensions_mutreturns&mut Extensions.RequestAlreadyExtractedhas been removed.<Request as FromRequest>::Rejectionis nowBodyAlreadyExtracted.<http::request::Parts as FromRequest>::Rejectionis nowInfallible.ExtensionsAlreadyExtractedhas been removed.- The
ExtensionsAlreadyExtractedremoved variant has been removed from these rejections:ExtensionRejectionPathRejectionMatchedPathRejectionWebSocketUpgradeRejection
-
breaking:
Redirect::foundhas been removed (#800) -
breaking:
AddExtensionLayerhas been removed. UseExtensioninstead. It now implements
tower::Layer(#807) -
breaking:
AddExtensionhas been moved from the root module tomiddleware -
breaking:
.nest("/foo/", Router::new().route("/bar", _))now does the right thing and
results in a route at/foo/barinstead of/foo//bar(#824) -
breaking: Routes are now required to start with
/. Previously routes such as:foowould
be accepted but most likely result in bugs (#823) -
breaking:
Headershas been removed. Arrays of tuples directly implement
IntoResponsePartsso([("x-foo", "foo")], response)now works (#797) -
breaking:
InvalidJsonBodyhas been replaced withJsonDataErrorto clearly signal that the
request body was syntactically valid JSON but couldn't be deserialized into the target type -
breaking:
Handleris no longer an#[async_trait]but instead has an
associatedFuturetype. That allows users to build their ownHandlertypes
without paying the cost of#[async_trait](#879) -
changed: New
JsonSyntaxErrorvariant added toJsonRejection. This is returned when the
request body contains syntactically invalid JSON -
fixed: Correctly set the
Content-Lengthheader for response toHEAD
requests (#734) -
fixed: Fix wrong
content-lengthforHEADrequests to endpoints that returns chunked
responses (#755) -
fixed: Fixed several routing bugs related to nested "opaque" tower services (i.e.
non-Routerservices) (#841 and #842) -
changed: Update to tokio-tungstenite 0.17 (#791)
-
breaking:
Redirect::{to, temporary, permanent}now accept&strinstead
ofUri(#889) -
breaking: Remove second type parameter from
Router::into_make_service_with_connect_info
andHandler::into_make_service_with_connect_infoto supportMakeServices
that accept multiple targets (#892)