Add multipart form data params to json export

This commit is contained in:
Fabrice Reix 2020-11-03 08:53:36 +01:00
parent cf7a4f215d
commit 8fe2e3daf3

View File

@ -101,6 +101,7 @@ impl Serialize for Request {
state.serialize_field("queryString", &self.clone().querystring)?;
state.serialize_field("headers", &self.clone().headers)?;
state.serialize_field("cookies", &self.clone().cookies)?;
state.serialize_field("multipartFormData", &self.clone().multipart)?;
if !self.clone().form.is_empty() {
state.serialize_field("form", &self.clone().form)?;
@ -227,6 +228,34 @@ impl Serialize for Cookie {
}
}
impl Serialize for MultipartParam {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match &self.clone() {
MultipartParam::Param(param) => param.serialize(serializer),
MultipartParam::FileParam(file_param) => file_param.serialize(serializer),
}
}
}
impl Serialize for FileParam {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut state = serializer.serialize_struct("FileParam", 4)?;
state.serialize_field("name", &self.clone().name)?;
if let Ok(s) = std::str::from_utf8(&self.clone().data) {
state.serialize_field("value", s)?;
}
state.serialize_field("fileName", &self.clone().filename)?;
state.serialize_field("contentType", &self.clone().content_type)?;
state.end()
}
}
impl Serialize for Value {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where