pub fn generate_response(response: &models::Response, context: &HashMap<String, Value>) -> models::Response {
  let generators = response.generators.clone();
  let mut response = response.clone();
  generators.apply_generator(&GeneratorCategory::STATUS, |_, generator| {
    match generator.generate_value(&response.status, context) {
      Some(v) => response.status = v,
      None => ()
    }
  });
  generators.apply_generator(&GeneratorCategory::HEADER, |key, generator| {
    match response.headers {
      Some(ref mut headers) => if headers.contains_key(key) {
        match generator.generate_value(&headers.get(key).unwrap().clone(), context) {
          Some(v) => headers.insert(key.clone(), v),
          None => None
        };
      },
      None => ()
    }
  });
  response.body = generators.apply_body_generators(&response.body, response.content_type_enum(),
    context);
  response
}
/// Generates the response by applying any defined generators
Generates the response by applying any defined generators
Generates the response by applying any defined generators
pub fn generate_response(response: &models::Response, context: &HashMap<String, Value>) -> models::Response {
  let generators = response.generators.clone();
  let mut response = response.clone();
  generators.apply_generator(&GeneratorCategory::STATUS, |_, generator| {
    match generator.generate_value(&response.status, context) {
      Some(v) => response.status = v,
      None => ()
    }
  });
  generators.apply_generator(&GeneratorCategory::HEADER, |key, generator| {
    match response.headers {
      Some(ref mut headers) => if headers.contains_key(key) {
        match generator.generate_value(&headers.get(key).unwrap().clone(), context) {
          Some(v) => headers.insert(key.clone(), v),
          None => None
        };
      },
      None => ()
    }
  });
  response.body = generators.apply_body_generators(&response.body, response.content_type_enum(),
    context);
  response
}
pub fn generate_response ( response : & models :: Response , context : & HashMap < String , Value > ) -> models :: Response { let generators = response . generators . clone ( ) ; let mut response = response . clone ( ) ; generators . apply_generator ( & GeneratorCategory :: STATUS , | _ , generator | { match generator . generate_value ( & response . status , context ) { Some ( v ) => response . status = v , None => ( ) } } ) ; generators . apply_generator ( & GeneratorCategory :: HEADER , | key , generator | { match response . headers { Some ( ref mut headers ) => if headers . contains_key ( key ) { match generator . generate_value ( & headers . get ( key ) . unwrap ( ) . clone ( ) , context ) { Some ( v ) => headers . insert ( key . clone ( ) , v ) , None => None } ; } , None => ( ) } } ) ; response . body = generators . apply_body_generators ( & response . body , response . content_type_enum ( ) , context ) ; response }
Generates the response by applying any defined generators
Generates the response by applying any defined generators
response
&models::Response
context
&HashMap<String, Value>
response
&models::Response
context
&HashMap<String, Value>