#json-xml #xml #protobuf #json #serde #serialization #serde-json

actix-multiresponse

actix-multiresponse intents to allow supporting multiple response/request data formats depending on the Content-Type and Accept headers

7 unstable releases (3 breaking)

0.4.2 Dec 30, 2022
0.4.1 Dec 30, 2022
0.3.0 Oct 26, 2022
0.2.0 Jul 3, 2022
0.1.0 Mar 13, 2022

#2235 in Encoding

40 downloads per month

MIT/Apache

23KB
451 lines

actix-multiresponse

actix-multiresponse intents to allow supporting multiple response/request data formats depending on the Content-Type and Accept header.

Supported formats

  • Json
  • Protobuf
  • XML

All formats can be enabled using equally-named feature flags. At least one format should be enabled. By default json and protobuf are enabled.

Example

use prost_derive::Message;
use serde_derive::{Deserialize, Serialize};
use actix_multiresponse::Payload;

#[derive(Deserialize, Serialize, Message, Clone)]
struct TestPayload {
    #[prost(string, tag = "1")]
    foo: String,
    #[prost(int64, tag = "2")]
    bar: i64,
}

async fn responder(payload: Payload<TestPayload>) -> Payload<TestPayload> {
    payload
}

License

actix-multiresponse is dual licensed under the MIT or the Apache-2.0 license, at your discretion


lib.rs:

actix-multiresponse intents to allow supporting multiple response/request data formats depending on the Content-Type and Accept headers.

Supported formats

  • Json
  • Protobuf

All formats can be enabled with feature flags. At least one format should be enabled to make this library useful.

Example

    use prost_derive::Message;
    use serde_derive::{Deserialize, Serialize};
    use actix_multiresponse::Payload;

    #[derive(Deserialize, Serialize, Message, Clone)]
    struct TestPayload {
        #[prost(string, tag = "1")]
        foo: String,
        #[prost(int64, tag = "2")]
        bar: i64,
    }

    async fn responder(payload: Payload<TestPayload>) -> Payload<TestPayload> {
        payload
    }

Dependencies

~14–26MB
~460K SLoC