1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 18:09:22 +02:00

add protobuf feature

This commit is contained in:
Nikolay Kim
2018-03-08 20:56:18 -08:00
parent 3f0803a7d3
commit f3c63e631a
10 changed files with 83 additions and 83 deletions

View File

@ -12,4 +12,4 @@ prost = "0.2.0"
prost-derive = "0.2.0"
actix = "0.5"
actix-web = { path="../../" }
actix-web = { path="../../", features=["protobuf"] }

View File

@ -8,6 +8,7 @@ extern crate prost;
extern crate prost_derive;
use actix_web::*;
use actix_web::ProtoBufBody;
use futures::Future;
@ -22,7 +23,7 @@ pub struct MyObj {
/// This handler uses `HttpRequest::json()` for loading serde json object.
fn index(req: HttpRequest) -> Box<Future<Item=HttpResponse, Error=Error>> {
req.protobuf()
ProtoBufBody::new(req)
.from_err() // convert all errors into `Error`
.and_then(|val: MyObj| {
println!("model: {:?}", val);