[][src]Crate hyper_multipart_rfc7578

This crate contains an implementation of the multipart/form-data media type described in RFC 7578 for hyper.

Usage

Declare the dependency:

[dependencies]
hyper-multipart-rfc7578 = "0.1.0"

Import the crate:

extern crate hyper_multipart_rfc7578 as multipart;

Example:

With a custom client:

use hyper::{
    rt::{self, Future},
    Client, Request,
};
use hyper_multipart::client::{self, multipart};

let client = Client::builder().build_http();
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");

let mut req_builder = Request::get("http://localhost/upload");

let req = form.set_body::<multipart::Body>(&mut req_builder).unwrap();

rt::run(
    client
        .request(req)
        .map(|_| println!("done..."))
        .map_err(|_| println!("an error occurred")),
);

With a default client:

use hyper::{
    rt::{self, Future},
    Client, Request,
};
use hyper_multipart::client::{self, multipart};

let client = Client::new();
let mut form = multipart::Form::default();

form.add_text("test", "Hello World");

let mut req_builder = Request::get("http://localhost/upload");

let req = form.set_body_convert::<hyper::Body, multipart::Body>(&mut req_builder)
    .unwrap();

rt::run(
    client
        .request(req)
        .map(|_| println!("done..."))
        .map_err(|_| println!("an error occurred")),
);

Modules

client