github tokio-rs/axum axum-v0.5.0
axum - v0.5.0

latest releases: axum-extra-v0.9.3, axum-v0.7.5, axum-macros-v0.4.1...
2 years ago
  • 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::Host for extracting the hostname of a request (#827)

  • added: Add IntoResponseParts trait which allows defining custom response
    types for adding headers or extensions to responses (#797)

  • added: TypedHeader implements the new IntoResponseParts trait so they
    can be returned from handlers as parts of a response (#797)

  • changed: Router::merge now accepts Into<Router> (#819)

  • breaking: sse::Event now accepts types implementing AsRef<str> instead of Into<String>
    as field values.

  • breaking: sse::Event now panics if a setter method is called twice instead of silently
    overwriting old values.

  • breaking: Require Output = () on WebSocketStream::on_upgrade (#644)

  • breaking: Make TypedHeaderRejectionReason #[non_exhaustive] (#665)

  • breaking: Using HeaderMap as an extractor will no longer remove the headers and thus
    they'll still be accessible to other extractors, such as axum::extract::Json. Instead
    HeaderMap will clone the headers. You should prefer to use TypedHeader to extract only the
    headers you need (#698)

    This includes these breaking changes:

    • RequestParts::take_headers has been removed.
    • RequestParts::headers returns &HeaderMap.
    • RequestParts::headers_mut returns &mut HeaderMap.
    • HeadersAlreadyExtracted has been removed.
    • The HeadersAlreadyExtracted variant has been removed from these rejections:
      • RequestAlreadyExtracted
      • RequestPartsAlreadyExtracted
      • JsonRejection
      • FormRejection
      • ContentLengthLimitRejection
      • WebSocketUpgradeRejection
    • <HeaderMap as FromRequest<_>>::Rejection has been changed to std::convert::Infallible.
  • breaking: axum::http::Extensions is no longer an extractor (ie it
    doesn't implement FromRequest). The axum::extract::Extension extractor 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_extensions has been removed.
    • RequestParts::extensions returns &Extensions.
    • RequestParts::extensions_mut returns &mut Extensions.
    • RequestAlreadyExtracted has been removed.
    • <Request as FromRequest>::Rejection is now BodyAlreadyExtracted.
    • <http::request::Parts as FromRequest>::Rejection is now Infallible.
    • ExtensionsAlreadyExtracted has been removed.
    • The ExtensionsAlreadyExtracted removed variant has been removed from these rejections:
      • ExtensionRejection
      • PathRejection
      • MatchedPathRejection
      • WebSocketUpgradeRejection
  • breaking: Redirect::found has been removed (#800)

  • breaking: AddExtensionLayer has been removed. Use Extension instead. It now implements
    tower::Layer (#807)

  • breaking: AddExtension has been moved from the root module to middleware

  • breaking: .nest("/foo/", Router::new().route("/bar", _)) now does the right thing and
    results in a route at /foo/bar instead of /foo//bar (#824)

  • breaking: Routes are now required to start with /. Previously routes such as :foo would
    be accepted but most likely result in bugs (#823)

  • breaking: Headers has been removed. Arrays of tuples directly implement
    IntoResponseParts so ([("x-foo", "foo")], response) now works (#797)

  • breaking: InvalidJsonBody has been replaced with JsonDataError to clearly signal that the
    request body was syntactically valid JSON but couldn't be deserialized into the target type

  • breaking: Handler is no longer an #[async_trait] but instead has an
    associated Future type. That allows users to build their own Handler types
    without paying the cost of #[async_trait] (#879)

  • changed: New JsonSyntaxError variant added to JsonRejection. This is returned when the
    request body contains syntactically invalid JSON

  • fixed: Correctly set the Content-Length header for response to HEAD
    requests (#734)

  • fixed: Fix wrong content-length for HEAD requests to endpoints that returns chunked
    responses (#755)

  • fixed: Fixed several routing bugs related to nested "opaque" tower services (i.e.
    non-Router services) (#841 and #842)

  • changed: Update to tokio-tungstenite 0.17 (#791)

  • breaking: Redirect::{to, temporary, permanent} now accept &str instead
    of Uri (#889)

  • breaking: Remove second type parameter from Router::into_make_service_with_connect_info
    and Handler::into_make_service_with_connect_info to support MakeServices
    that accept multiple targets (#892)

Don't miss a new axum release

NewReleases is sending notifications on new releases.