Upgrading actix-web 1 to 2
Breaking1.0.9 → 2.0.0Breaking9Platform1New2Changed9Fixed5
BreakingUpgrade verdict
9 breaking changes and a platform requirement change.
In plain terms
- 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.
Must act Top 4 of 10 that need code or config changes
What you must change
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 ().ResponderRemoves the content_length function; set Content-Length by calling no_chunking instead.
content_lengthno_chunkingRemoves the BodySize::Sized64 variant; BodySize::Sized now takes a u64 instead of a usize.
BodySize::Sized64BodySize::SizedRemoves
failure support for ResponseError since that crate will be deprecated soon.ResponseErrorfailureMoves
BodyEncoding to the dev module.BodyEncodingdevHttpRequest::app_data<T>() returns Option<&T> instead of Option<&Data<T>>.HttpRequest::app_data<T>()DataMakes
test_server an async fn.test_serverPlatform1
Bumps the minimum supported Rust version to 1.40.