#actix #json #actix-web

macro actix-json-responder

A procedural macro to reduce json response boilerplate on actix projects

3 unstable releases

0.2.0 Mar 3, 2022
0.2.0-beta.1 Jan 11, 2022
0.1.0 Jun 23, 2021

#1309 in Procedural macros

Download history 2/week @ 2022-08-12 6/week @ 2022-08-19 3/week @ 2022-08-26 3/week @ 2022-09-02 15/week @ 2022-09-09 4/week @ 2022-09-23 1/week @ 2022-09-30 1/week @ 2022-10-14 1/week @ 2022-10-21 1/week @ 2022-10-28 36/week @ 2022-11-04 26/week @ 2022-11-11 2/week @ 2022-11-18 3/week @ 2022-11-25

67 downloads per month

MIT/Apache

7KB

Actix Json Responder Continuous Integration license-badge rust-version-badge

A procedural macro to reduce json response boilerplate on actix projects.

Usage

Implementing struct has to be serializable. Example shown in tests and below:

#[macro_use]
extern crate actix_json_responder;

use serde::Serialize;
use actix_web::{web, App, HttpServer};

#[derive(Serialize, JsonResponder, PartialEq)]
struct HelloStruct {
    title: String,
}

async fn index() -> Result<HelloStruct, Error> {
    Ok(HelloStruct { title: "Hello json!".to_string() })
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new()
        .service(web::resource("/index.html").to(index)))
        .bind("127.0.0.1:8888")?
        .run()
        .await
}

Working example is in example directory.

License

Distributed under the terms of MIT license and Apache license.

Dependencies

~200–580KB
~14K SLoC