1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 01:51:23 +02:00

update example

This commit is contained in:
Nikolay Kim
2017-12-20 16:13:21 -08:00
parent 50891986bc
commit 4dd3382ac7
2 changed files with 10 additions and 17 deletions

View File

@ -85,11 +85,9 @@ fn index(mut req: HttpRequest) -> Future<Item=HttpResponse, Error=Error> {
.from_err()
// `Future::and_then` can be used to merge an asynchronous workflow with a
// synchronous workflow
.and_then(|body| { // <- body is loaded, now we can deserialize json
let obj = serde_json::from_slice::<MyObj>(&body).unwrap();
ok(httpcodes::HTTPOk.build() // <- send response
.content_type("application/json")
.json(obj).unwrap())
.and_then(|body| { // <- body is loaded, now we can deserialize json
let obj = serde_json::from_slice::<MyObj>(&body)?;
Ok(httpcodes::HTTPOk.build().json(obj)?) // <- send response
})
}
```