updated tide for better routes #8

Merged
JakeHillion merged 1 commits from update-tide into main 2022-07-25 13:41:22 +01:00
4 changed files with 68 additions and 54 deletions

114
Cargo.lock generated
View File

@ -188,20 +188,20 @@ dependencies = [
[[package]]
name = "async-session"
version = "2.0.1"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "345022a2eed092cd105cc1b26fd61c341e100bd5fcbbd792df4baf31c2cc631f"
checksum = "07da4ce523b4e2ebaaf330746761df23a465b951a83d84bbce4233dabedae630"
dependencies = [
"anyhow",
"async-std",
"async-lock",
"async-trait",
"base64 0.12.3",
"base64",
"bincode",
"blake3",
"chrono",
"hmac 0.8.1",
"kv-log-macro",
"rand 0.7.3",
"hmac 0.11.0",
"log",
"rand 0.8.5",
"serde",
"serde_json",
"sha2",
@ -283,12 +283,6 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270"
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.0"
@ -394,7 +388,6 @@ dependencies = [
"num-integer",
"num-traits",
"serde",
"time 0.1.44",
"winapi",
]
@ -435,13 +428,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951"
dependencies = [
"aes-gcm",
"base64 0.13.0",
"base64",
"hkdf",
"hmac 0.10.1",
"percent-encoding",
"rand 0.8.5",
"sha2",
"time 0.2.27",
"time",
"version_check",
]
@ -490,6 +483,16 @@ dependencies = [
"subtle",
]
[[package]]
name = "crypto-mac"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
dependencies = [
"generic-array",
"subtle",
]
[[package]]
name = "ctor"
version = "0.1.22"
@ -769,16 +772,6 @@ dependencies = [
"hmac 0.10.1",
]
[[package]]
name = "hmac"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840"
dependencies = [
"crypto-mac 0.8.0",
"digest",
]
[[package]]
name = "hmac"
version = "0.10.1"
@ -789,6 +782,16 @@ dependencies = [
"digest",
]
[[package]]
name = "hmac"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
dependencies = [
"crypto-mac 0.11.1",
"digest",
]
[[package]]
name = "http-client"
version = "6.5.3"
@ -810,7 +813,7 @@ dependencies = [
"anyhow",
"async-channel",
"async-std",
"base64 0.13.0",
"base64",
"cookie",
"futures-lite",
"infer",
@ -1238,10 +1241,14 @@ dependencies = [
]
[[package]]
name = "route-recognizer"
version = "0.2.0"
name = "routefinder"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56770675ebc04927ded3e60633437841581c285dc6236109ea25fbf3beb7b59e"
checksum = "a44ef95cc607e41a7021da5cfb0f357ee0805113af2e9e6c617857c260940db4"
dependencies = [
"smartcow",
"smartstring",
]
[[package]]
name = "rust-embed"
@ -1475,6 +1482,24 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "smartcow"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05e3ed3ccf93c7425507e5e2261a3fc90d14267d491f360b9b679ae0a4ce693e"
dependencies = [
"smartstring",
]
[[package]]
name = "smartstring"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e714dff2b33f2321fdcd475b71cec79781a692d846f37f415fb395a1d2bcd48e"
dependencies = [
"static_assertions",
]
[[package]]
name = "socket2"
version = "0.4.4"
@ -1494,6 +1519,12 @@ dependencies = [
"version_check",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stdweb"
version = "0.4.20"
@ -1591,9 +1622,9 @@ dependencies = [
[[package]]
name = "tide"
version = "0.16.0"
version = "0.17.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c459573f0dd2cc734b539047f57489ea875af8ee950860ded20cf93a79a1dee0"
checksum = "c5a885fbeb66af9d607a731ce167e3fdfe65e49a68f37f4bbd8618b5efc6ad51"
dependencies = [
"async-h1",
"async-session",
@ -1607,22 +1638,11 @@ dependencies = [
"kv-log-macro",
"log",
"pin-project-lite 0.2.9",
"route-recognizer",
"routefinder",
"serde",
"serde_json",
]
[[package]]
name = "time"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]]
name = "time"
version = "0.2.27"
@ -1775,12 +1795,6 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"

View File

@ -11,7 +11,7 @@ thiserror = "1"
async-std = "1"
tide = "0.16.0"
tide = "0.17.0-beta.1"
diesel = { version = "1.4", features = ["postgres", "r2d2"] }
diesel_migrations = "1.4"

View File

@ -30,7 +30,7 @@ fn main() -> Result<(), io::Error> {
let db = db::new().unwrap();
let mut app = tide::new();
app.at("/_api").nest(serve_api(db));
app.at("/_api/").nest(serve_api(db));
app.at("/").nest(serve_react());
task::block_on(app.listen("127.0.0.1:8080"))

View File

@ -14,8 +14,8 @@ pub fn serve() -> tide::Server<()> {
app.at("/").get(|_| async { serve_internal(INDEX) });
app.at("/*path").get(|r: Request<()>| {
let path = r.param("path").unwrap().to_string();
app.at("/*").get(|r: Request<()>| {
let path = r.wildcard().unwrap().to_string();
async move { serve_internal(path.as_str()) }
});