actix-json-responder

Crates.ioactix-json-responder
lib.rsactix-json-responder
version0.2.1
sourcesrc
created_at2021-06-23 12:48:06.774504
updated_at2022-12-28 07:31:08.324965
descriptionA procedural macro to reduce json response boilerplate on actix projects.
homepage
repositoryhttps://github.com/eisberg-labs/actix-json-responder
max_upload_size
id413911
size16,981
Ana Bujan (amarjanica)

documentation

README

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.

Commit count: 19

cargo fmt