1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-01 01:16:59 +02:00

Add protobuf support

This commit is contained in:
kingxsp
2018-03-09 10:05:13 +08:00
parent ebdc983dfe
commit a0b589eb96
11 changed files with 400 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ use bytes::{Bytes, BytesMut};
use futures::{Future, Stream, Poll};
use http_range::HttpRange;
use serde::de::DeserializeOwned;
use prost::Message;
use mime::Mime;
use url::form_urlencoded;
use encoding::all::UTF_8;
@@ -12,6 +13,7 @@ use encoding::label::encoding_from_whatwg_label;
use http::{header, HeaderMap};
use json::JsonBody;
use protobuf::ProtoBufBody;
use header::Header;
use multipart::Multipart;
use error::{ParseError, ContentTypeError,
@@ -209,6 +211,12 @@ pub trait HttpMessage {
JsonBody::new(self)
}
fn protobuf<T: Message + Default>(self) -> ProtoBufBody<Self, T>
where Self: Stream<Item=Bytes, Error=PayloadError> + Sized
{
ProtoBufBody::new(self)
}
/// Return stream to http payload processes as multipart.
///
/// Content-type: multipart/form-data;