#forms #macro-derive #actix #derive #macro #multipart-form #multipart

macro actix-multipart-derive-impl

Procedural derive macro implementation for actix-multipart-derive

1 unstable release

0.1.0 Nov 9, 2020

#35 in #multipart-form

MIT/Apache

8KB
142 lines

actix-multipart-derive

WIP derive macro wrapping actix-multipart to make multipart forms easier to consume.

Goal

Consuming multipart forms should be expressive while maintaining it's stream-oriented implementation under the hood.

use actix_multipart_derive::MultipartForm;
use actix_web::{post, web::BytesMut, App, HttpServer};

#[derive(Debug, Clone, Default, MultipartForm)]
struct Form {
    name: String,

    #[multipart(max_size = 1024)]
    file: BytesMut,
}

#[post("/")]
async fn index(form: Form) -> &'static str {
    println!("{:?}", &form);

    "Hello world!\r\n"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new().service(index))
        .bind("127.0.0.1:8080")?
        .workers(1)
        .run()
        .await
}

Dependencies

~1.5MB
~35K SLoC