Skip to content

Commit

Permalink
fix: after upgrading crates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Jun 24, 2020
1 parent cd7e60f commit 9a5a36d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion native/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pact-js-v3"
version = "0.0.3"
version = "0.0.4"
authors = ["Ronald Holshausen <uglyog@gmail.com>"]
license = "MIT"
build = "build.rs"
Expand Down
13 changes: 9 additions & 4 deletions native/src/lib.rs
Expand Up @@ -49,11 +49,16 @@ fn process_xml(body: String, matching_rules: &mut Category, generators: &mut Gen
}
}

fn process_body(body: String, content_type: DetectedContentType, matching_rules: &mut MatchingRules, generators: &mut Generators) -> Result<OptionalBody, String> {
fn process_body(
body: String,
content_type: DetectedContentType,
matching_rules: &mut MatchingRules,
generators: &mut Generators
) -> Result<OptionalBody, String> {
let category = matching_rules.add_category("body");
match content_type {
DetectedContentType::Json => Ok(OptionalBody::from(process_json(body, category, generators))),
DetectedContentType::Xml => Ok(OptionalBody::Present(process_xml(body, category, generators)?)),
DetectedContentType::Json => Ok(OptionalBody::Present(process_json(body, category, generators).as_bytes().to_vec(), Some("application/json".into()))),
DetectedContentType::Xml => Ok(OptionalBody::Present(process_xml(body, category, generators)?, Some("application/xml".into()))),
_ => Ok(OptionalBody::from(body))
}
}
Expand Down Expand Up @@ -177,7 +182,7 @@ fn get_headers(cx: &mut CallContext<JsPact>, obj: Handle<JsObject>) -> NeonResul
}

fn load_file(file_path: &String) -> Result<OptionalBody, std::io::Error> {
fs::read(file_path).map(|data| OptionalBody::Present(data))
fs::read(file_path).map(|data| OptionalBody::Present(data, None))
}

declare_types! {
Expand Down

0 comments on commit 9a5a36d

Please sign in to comment.