1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-23 16:21:06 +01:00

add payload stream migration entry

This commit is contained in:
Nikolay Kim 2019-05-04 22:18:02 -07:00
parent 005c055a7f
commit 33b4c05557
2 changed files with 31 additions and 1 deletions

View File

@ -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"

View File

@ -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<Future<Item=HttpResponse, Error=Error>> {
req
.payload()
.from_err()
.fold((), |_, chunk| {
...
})
.map(|_| HttpResponse::Ok().finish())
.responder()
}
```
use `Payload` extractor
```rust
fn index(stream: web::Payload) -> impl Future<Item=HttpResponse, Error=Error> {
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.