Skip to content

Commit ad573ca

Browse files
authored
Merge pull request #8 from calcit-lang/calcit-0.7
upgrade calcit 0.7
2 parents 737ecb0 + 94c4b96 commit ad573ca

File tree

6 files changed

+32
-31
lines changed

6 files changed

+32
-31
lines changed

.github/workflows/check.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ jobs:
1515

1616
- uses: supplypike/setup-bin@v3
1717
with:
18-
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.6.23/cr'
18+
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/cr'
1919
name: 'cr'
20-
version: '0.6.23'
20+
version: '0.7.0-a3'
2121

2222
- uses: supplypike/setup-bin@v3
2323
with:
24-
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.6.23/caps'
24+
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.0-a3/caps'
2525
name: 'caps'
26-
version: '0.6.23'
26+
version: '0.7.0-a3'
2727

28-
- uses: actions-rs/toolchain@v1
28+
- uses: dtolnay/rust-toolchain@stable
2929
with:
30-
toolchain: stable
30+
# toolchain: nightly
31+
components: clippy
3132

3233
- run: cargo build --release
3334

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.9"
3+
version = "0.1.0"
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.2.21"
16+
cirru_edn = "0.4.0"
1717
cirru_parser = "0.1.24"
1818
tiny_http = "0.12.0"
1919
querystring = "1.1.0"

calcit.cirru

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compact.cirru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{} (:package |http)
3-
:configs $ {} (:init-fn |http.test/main!) (:reload-fn |http.test/reload!) (:version |0.0.6)
3+
:configs $ {} (:init-fn |http.test/main!) (:reload-fn |http.test/reload!) (:version |0.1.0)
44
:modules $ []
55
:entries $ {}
66
:server $ {} (:init-fn |http.test/demo-server!) (:reload-fn |http.test/reload!)

src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,39 @@ pub fn serve_http(
4141
// );
4242

4343
let mut m: HashMap<Edn, Edn> = HashMap::new();
44-
m.insert(Edn::kwd("method"), Edn::kwd(&request.method().to_string()));
44+
m.insert(Edn::tag("method"), Edn::tag(&request.method().to_string()));
4545
let url = request.url().to_string();
46-
m.insert(Edn::kwd("url"), Edn::str(url.to_owned()));
46+
m.insert(Edn::tag("url"), Edn::str(url.to_owned()));
4747

4848
match url.split_once('?') {
4949
Some((path_part, query_part)) => {
50-
m.insert(Edn::kwd("path"), path_part.into());
51-
m.insert(Edn::kwd("querystring"), query_part.into());
50+
m.insert(Edn::tag("path"), path_part.into());
51+
m.insert(Edn::tag("querystring"), query_part.into());
5252
let query = querystring::querify(query_part);
5353
let mut query_dict = HashMap::new();
5454
for (k, v) in query {
55-
query_dict.insert(Edn::kwd(k), v.into());
55+
query_dict.insert(Edn::tag(k), v.into());
5656
}
57-
m.insert(Edn::kwd("query"), Edn::Map(query_dict));
57+
m.insert(Edn::tag("query"), Edn::Map(query_dict));
5858
}
5959
None => {
60-
m.insert(Edn::kwd("path"), url.into());
61-
m.insert(Edn::kwd("querystring"), "".into());
62-
m.insert(Edn::kwd("query"), Edn::Map(HashMap::new()));
60+
m.insert(Edn::tag("path"), url.into());
61+
m.insert(Edn::tag("querystring"), "".into());
62+
m.insert(Edn::tag("query"), Edn::Map(HashMap::new()));
6363
}
6464
}
6565

6666
let mut headers: HashMap<Edn, Edn> = HashMap::new();
6767

6868
for pair in request.headers() {
69-
headers.insert(Edn::kwd(&pair.field.to_string()), Edn::str(pair.value.to_string()));
69+
headers.insert(Edn::tag(&pair.field.to_string()), Edn::str(pair.value.to_string()));
7070
}
71-
m.insert(Edn::kwd("headers"), Edn::Map(headers));
71+
m.insert(Edn::tag("headers"), Edn::Map(headers));
7272

7373
if request.method() != &Method::Get {
7474
let mut content = String::new();
7575
request.as_reader().read_to_string(&mut content).unwrap();
76-
m.insert(Edn::kwd("body"), Edn::Str(content.to_string().into_boxed_str()));
76+
m.insert(Edn::tag("body"), Edn::Str(content.to_string().into_boxed_str()));
7777
}
7878

7979
let info = Edn::Map(m);
@@ -102,12 +102,12 @@ fn parse_options(d: &Edn) -> Result<HttpServerOptions, String> {
102102
port: 4000,
103103
host: String::from("0.0.0.0").into_boxed_str(),
104104
};
105-
options.port = match m.get(&Edn::kwd("port")) {
105+
options.port = match m.get(&Edn::tag("port")) {
106106
Some(Edn::Number(port)) => *port as u16,
107107
None => 4000,
108108
a => return Err(format!("invalid config for port: {:?}", a)),
109109
};
110-
options.host = match m.get(&Edn::kwd("host")) {
110+
options.host = match m.get(&Edn::tag("host")) {
111111
Some(Edn::Str(host)) => host.to_owned(),
112112
None => String::from("0.0.0.0").into_boxed_str(),
113113
a => return Err(format!("invalid config for host: {:?}", a)),
@@ -126,21 +126,21 @@ fn parse_response(info: &Edn) -> Result<ResponseSkeleton, String> {
126126
headers: HashMap::new(),
127127
body: String::from("").into_boxed_str(),
128128
};
129-
res.code = match m.get(&Edn::kwd("code")) {
129+
res.code = match m.get(&Edn::tag("code")) {
130130
Some(Edn::Number(n)) => *n as u8,
131131
None => 200,
132132
a => return Err(format!("invalid code: {:?}", a)),
133133
};
134-
res.body = match m.get(&Edn::kwd("body")) {
134+
res.body = match m.get(&Edn::tag("body")) {
135135
Some(Edn::Str(s)) => s.to_owned(),
136136
Some(a) => a.to_string().into_boxed_str(),
137137
None => String::from("").into_boxed_str(),
138138
};
139-
res.headers = match m.get(&Edn::kwd("headers")) {
139+
res.headers = match m.get(&Edn::tag("headers")) {
140140
Some(Edn::Map(m)) => {
141141
let mut hs: HashMap<Box<str>, Box<str>> = HashMap::new();
142142
for (k, v) in m {
143-
let k: Box<str> = if let Edn::Keyword(s) = k {
143+
let k: Box<str> = if let Edn::Tag(s) = k {
144144
s.to_str()
145145
} else if let Edn::Str(s) = k {
146146
s.to_owned()

0 commit comments

Comments
 (0)