Skip to content

Upgrading actix-web 1 to 2

Breaking1.0.9 → 2.0.0Breaking9Platform1New2Changed9Fixed5

BreakingUpgrade verdict

9 breaking changes and a platform requirement change.

  • The method for registering shared application data has a new name.
  • The old server run method is removed because async/await makes it unnecessary.
  • Handlers can no longer return unit as a response.
  • The old way to set a content length is gone; use the no_chunking option instead.
Top 4 of 10 that need code or config changes
Breaking9
Renames App::register_data() to App::app_data().
App::register_data()App::app_data()
Deletes HttpServer::run(), which is not useful with async/await.
HttpServer::run()
Removes the implementation of Responder for ().
Responder
Removes the content_length function; set Content-Length by calling no_chunking instead.
content_lengthno_chunking
Removes the BodySize::Sized64 variant; BodySize::Sized now takes a u64 instead of a usize.
BodySize::Sized64BodySize::Sized
Removes failure support for ResponseError since that crate will be deprecated soon.
ResponseErrorfailure
Moves BodyEncoding to the dev module.
BodyEncodingdev
HttpRequest::app_data<T>() returns Option<&T> instead of Option<&Data<T>>.
HttpRequest::app_data<T>()Data
Makes test_server an async fn.
test_server
Platform1
Bumps the minimum supported Rust version to 1.40.