swagger/multipart/
related.rs1use hyper_0_10::header::{ContentType, Headers};
4use mime_0_2::Mime;
5
6pub fn generate_boundary() -> Vec<u8> {
11 let mut boundary = mime_multipart::generate_boundary();
12 for b in boundary.iter_mut() {
13 if *b == b'/' {
14 *b = b'.';
15 }
16 }
17
18 boundary
19}
20
21pub fn create_multipart_headers(
24 content_type: Option<&hyper::header::HeaderValue>,
25) -> Result<Headers, String> {
26 let content_type = content_type
27 .ok_or_else(|| "Missing Content-Type header".to_string())?
28 .to_str()
29 .map_err(|e| format!("Couldn't read Content-Type header value: {}", e))?
30 .parse::<Mime>()
31 .map_err(|_e| "Couldn't parse Content-Type header value".to_string())?;
32
33 let mut multipart_headers = Headers::new();
35 multipart_headers.set(ContentType(content_type));
36
37 Ok(multipart_headers)
38}