Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ name: Test
jobs:
build_and_test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
Expand All @@ -20,7 +20,7 @@ jobs:
- name: add cr
run: |
mkdir -p $GITHUB_WORKSPACE/bin
wget -O $GITHUB_WORKSPACE/bin/cr https://github.com/calcit-lang/calcit/releases/download/0.6.1/cr
wget -O $GITHUB_WORKSPACE/bin/cr https://github.com/calcit-lang/calcit/releases/download/0.6.19/cr
chmod +x $GITHUB_WORKSPACE/bin/cr
echo "::add-path::$GITHUB_WORKSPACE/bin"

Expand Down
132 changes: 15 additions & 117 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "calcit_http"
version = "0.0.8"
version = "0.0.9"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
edition = "2021"

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

[dependencies]
cirru_edn = "0.2.15"
cirru_parser = "0.1.18"
tiny_http = "0.11.0"
cirru_edn = "0.2.21"
cirru_parser = "0.1.24"
tiny_http = "0.12.0"
querystring = "1.1.0"
21 changes: 20 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ pub fn serve_http(

let mut m: HashMap<Edn, Edn> = HashMap::new();
m.insert(Edn::kwd("method"), Edn::kwd(&request.method().to_string()));
m.insert(Edn::kwd("url"), Edn::str(request.url().to_string()));
let url = request.url().to_string();
m.insert(Edn::kwd("url"), Edn::str(url.to_owned()));

match url.split_once('?') {
Some((path_part, query_part)) => {
m.insert(Edn::kwd("path"), path_part.into());
m.insert(Edn::kwd("querystring"), query_part.into());
let query = querystring::querify(query_part);
let mut query_dict = HashMap::new();
for (k, v) in query {
query_dict.insert(Edn::kwd(k), v.into());
}
m.insert(Edn::kwd("query"), Edn::Map(query_dict));
}
None => {
m.insert(Edn::kwd("path"), url.into());
m.insert(Edn::kwd("querystring"), "".into());
m.insert(Edn::kwd("query"), Edn::Map(HashMap::new()));
}
}

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

Expand Down