pub fn apply_body_generators(&self, body: &OptionalBody, content_type: DetectedContentType, context: &HashMap<String, Value>) -> OptionalBody {
    if body.is_present() && self.categories.contains_key(&GeneratorCategory::BODY) &&
      !self.categories[&GeneratorCategory::BODY].is_empty() {
      let generators = &self.categories[&GeneratorCategory::BODY];
      match content_type {
        DetectedContentType::Json => {
          let result: Result<Value, serde_json::Error> = serde_json::from_slice(&body.value());
          match result {
            Ok(val) => {
              let mut handler = JsonHandler { value: val };
              handler.process_body(&generators, context)
            },
            Err(err) => {
              error!("Failed to parse the body, so not applying any generators: {}", err);
              body.clone()
            }
          }
        },
        DetectedContentType::Xml => match parse_bytes(&body.value()) {
          Ok(val) => {
            let mut handler = XmlHandler { value: val.as_document() };
            handler.process_body(&generators, context)
          },
          Err(err) => {
            error!("Failed to parse the body, so not applying any generators: {}", err);
            body.clone()
          }
        },
        _ => body.clone()
      }
    } else {
      body.clone()
    }
  }
/// Applies all the body generators to the body and returns a new body (if anything was applied).
Applies all the body generators to the body and returns a new body (if anything was applied).
Applies all the body generators to the body and returns a new body ( if anything was applied ) .
pub fn apply_body_generators(&self, body: &OptionalBody, content_type: DetectedContentType, context: &HashMap<String, Value>) -> OptionalBody {
    if body.is_present() && self.categories.contains_key(&GeneratorCategory::BODY) &&
      !self.categories[&GeneratorCategory::BODY].is_empty() {
      let generators = &self.categories[&GeneratorCategory::BODY];
      match content_type {
        DetectedContentType::Json => {
          let result: Result<Value, serde_json::Error> = serde_json::from_slice(&body.value());
          match result {
            Ok(val) => {
              let mut handler = JsonHandler { value: val };
              handler.process_body(&generators, context)
            },
            Err(err) => {
              error!("Failed to parse the body, so not applying any generators: {}", err);
              body.clone()
            }
          }
        },
        DetectedContentType::Xml => match parse_bytes(&body.value()) {
          Ok(val) => {
            let mut handler = XmlHandler { value: val.as_document() };
            handler.process_body(&generators, context)
          },
          Err(err) => {
            error!("Failed to parse the body, so not applying any generators: {}", err);
            body.clone()
          }
        },
        _ => body.clone()
      }
    } else {
      body.clone()
    }
  }
pub fn apply_body_generators ( & self , body : & OptionalBody , content_type : DetectedContentType , context : & HashMap < String , Value > ) -> OptionalBody { if body . is_present ( ) && self . categories . contains_key ( & GeneratorCategory :: BODY ) && ! self . categories [ & GeneratorCategory :: BODY ] . is_empty ( ) { let generators = & self . categories [ & GeneratorCategory :: BODY ] ; match content_type { DetectedContentType :: Json => { let result : Result < Value , serde_json :: Error > = serde_json :: from_slice ( & body . value ( ) ) ; match result { Ok ( val ) => { let mut handler = JsonHandler { value : val } ; handler . process_body ( & generators , context ) } , Err ( err ) => { error ! ( " " err ) ; body . clone ( ) } } } , DetectedContentType :: Xml => match parse_bytes ( & body . value ( ) ) { Ok ( val ) => { let mut handler = XmlHandler { value : val . as_document ( ) } ; handler . process_body ( & generators , context ) } , Err ( err ) => { error ! ( " " err ) ; body . clone ( ) } } , _ => body . clone ( ) } } else { body . clone ( ) } }
Applies all the body generators to the body and returns a new body (if anything was applied).
Applies all the body generators to the body and returns a new body ( if anything was applied ) .
&self
body
&OptionalBody
content_type
DetectedContentType
context
&HashMap<String, Value>
&self
body
&OptionalBody
content_type
DetectedContentType
context
&HashMap<String, Value>