From 33b4c055570a8ecad567797ea6187919109862db Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 4 May 2019 22:18:02 -0700 Subject: [PATCH] add payload stream migration entry --- Cargo.toml | 2 +- MIGRATION.md | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d880ac88..a8714846 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,7 +86,7 @@ hashbrown = "0.2.2" log = "0.4" mime = "0.3" net2 = "0.2.33" -parking_lot = "0.7" +parking_lot = "0.8" regex = "1.0" serde = { version = "1.0", features=["derive"] } serde_json = "1.0" diff --git a/MIGRATION.md b/MIGRATION.md index c7932b60..a07a6508 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -92,6 +92,36 @@ App.new().service(web::resource("/welcome").to(welcome)) ``` +* `HttpRequest` does not provide access to request's payload stream. + + instead of + + ```rust +fn index(req: &HttpRequest) -> Box> { + req + .payload() + .from_err() + .fold((), |_, chunk| { + ... + }) + .map(|_| HttpResponse::Ok().finish()) + .responder() +} + ``` + + use `Payload` extractor + + ```rust +fn index(stream: web::Payload) -> impl Future { + stream + .from_err() + .fold((), |_, chunk| { + ... + }) + .map(|_| HttpResponse::Ok().finish()) +} + ``` + * `State` is now `Data`. You register Data during the App initialization process and then access it from handlers either using a Data extractor or using HttpRequest's api.