Skip to content

Commit 009cc38

Browse files
committed
allow string as field of headers; tag 0.0.8
1 parent 8aa8a8f commit 009cc38

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "calcit_http"
3-
version = "0.0.7"
3+
version = "0.0.8"
44
authors = ["jiyinyiyong <[email protected]>"]
55
edition = "2018"
66

@@ -13,6 +13,6 @@ crate-type = ["dylib"] # Creates dynamic lib
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
cirru_edn = "0.2.14"
16+
cirru_edn = "0.2.15"
1717
cirru_parser = "0.1.18"
1818
tiny_http = "0.11.0"

calcit.cirru

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,19 @@ fn parse_response(info: &Edn) -> Result<ResponseSkeleton, String> {
121121
Some(Edn::Map(m)) => {
122122
let mut hs: HashMap<Box<str>, Box<str>> = HashMap::new();
123123
for (k, v) in m {
124-
if let Edn::Keyword(s) = k {
125-
if let Edn::Str(s2) = v {
126-
hs.insert(s.to_str(), s2.to_owned());
127-
} else {
128-
hs.insert(s.to_str(), v.to_string().into_boxed_str());
129-
}
124+
let k: Box<str> = if let Edn::Keyword(s) = k {
125+
s.to_str()
126+
} else if let Edn::Str(s) = k {
127+
s.to_owned()
130128
} else {
131129
return Err(format!("invalid head entry: {}", k));
132-
}
130+
};
131+
let value = if let Edn::Str(s2) = v {
132+
s2.to_owned()
133+
} else {
134+
v.to_string().into_boxed_str()
135+
};
136+
hs.insert(k, value);
133137
}
134138
hs
135139
}

0 commit comments

Comments
 (0)