Skip to content

Commit 456cf55

Browse files
committed
upgrade ABI version; expose remote-addr info; tag 0.1.4
1 parent 37d2ad7 commit 456cf55

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

.github/workflows/check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
- uses: calcit-lang/[email protected]
1717
with:
18-
version: "0.8.51"
18+
version: "0.8.59"
1919

2020
- uses: dtolnay/rust-toolchain@stable
2121
with:

Cargo.lock

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

Cargo.toml

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

@@ -13,7 +13,7 @@ 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.6.5"
17-
cirru_parser = "0.1.29"
16+
cirru_edn = "0.6.11"
17+
cirru_parser = "0.1.31"
1818
tiny_http = "0.12.0"
1919
querystring = "1.1.0"

src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct ResponseSkeleton {
1616

1717
#[no_mangle]
1818
pub fn abi_version() -> String {
19-
String::from("0.0.8")
19+
String::from("0.0.9")
2020
}
2121

2222
#[no_mangle]
@@ -41,9 +41,24 @@ pub fn serve_http(
4141
// );
4242

4343
let mut m: HashMap<Edn, Edn> = HashMap::new();
44-
m.insert(Edn::tag("method"), Edn::tag(&request.method().to_string()));
44+
m.insert(Edn::tag("method"), Edn::tag(request.method().to_string()));
4545
let url = request.url().to_string();
4646
m.insert(Edn::tag("url"), Edn::str(url.to_owned()));
47+
m.insert(Edn::tag("secure"), Edn::Bool(request.secure()));
48+
m.insert(
49+
Edn::tag("body-length"),
50+
match request.body_length() {
51+
Some(v) => Edn::Number(v as f64),
52+
None => Edn::Nil,
53+
},
54+
);
55+
m.insert(
56+
Edn::tag("remote-addr"),
57+
match request.remote_addr() {
58+
Some(addr) => Edn::str(addr.to_string()),
59+
None => Edn::Nil,
60+
},
61+
);
4762

4863
match url.split_once('?') {
4964
Some((path_part, query_part)) => {
@@ -66,7 +81,7 @@ pub fn serve_http(
6681
let mut headers: HashMap<Edn, Edn> = HashMap::new();
6782

6883
for pair in request.headers() {
69-
headers.insert(Edn::tag(&pair.field.to_string()), Edn::str(pair.value.to_string()));
84+
headers.insert(Edn::tag(pair.field.to_string()), Edn::str(pair.value.to_string()));
7085
}
7186
m.insert(Edn::tag("headers"), Edn::Map(EdnMapView(headers)));
7287

0 commit comments

Comments
 (0)