diff --git a/Cargo.lock b/Cargo.lock index d908f78..4907598 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "actix-codec" -version = "0.4.0-beta.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90673465c6187bd0829116b02be465dc0195a74d7719f76ffff0effef934a92e" +checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a" dependencies = [ "bitflags", "bytes", @@ -20,9 +20,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.0-beta.3" +version = "3.0.0-beta.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a12706e793a92377f85cec219514b72625b3b89f9b4912d8bfb53ab6a615bf0" +checksum = "3cd16d6b846983ffabfd081e1a67abd7698094fcbe7b3d9bcf1acbc6f546a516" dependencies = [ "actix-codec", "actix-rt", @@ -35,40 +35,38 @@ dependencies = [ "brotli2", "bytes", "bytestring", - "cookie", "derive_more", "encoding_rs", "flate2", - "futures-channel", "futures-core", "futures-util", "h2", "http", "httparse", - "indexmap", "itoa", "language-tags", - "lazy_static", + "local-channel", "log", "mime", + "once_cell", "percent-encoding", - "pin-project 1.0.5", + "pin-project", + "pin-project-lite", "rand 0.8.3", "regex", "serde", - "serde_json", - "serde_urlencoded", "sha-1", - "slab", "smallvec", "time 0.2.25", + "tokio", + "zstd", ] [[package]] name = "actix-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb2b608f0accc2f5bcf3dd872194ce13d94ee45b571487035864cf966b04ef" +checksum = "c2f86cd6857c135e6e9fe57b1619a88d1f94a7df34c00e11fe13e64fd3438837" dependencies = [ "quote", "syn", @@ -89,9 +87,9 @@ dependencies = [ [[package]] name = "actix-rt" -version = "2.0.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88cf46527e27f66efcd5831f60b3d9c2dac795b6d255ed17791752d6c36a8ea" +checksum = "bc7d7cd957c9ed92288a7c3c96af81fa5291f65247a76a34dac7b6af74e52ba0" dependencies = [ "actix-macros", "futures-core", @@ -118,19 +116,20 @@ dependencies = [ [[package]] name = "actix-service" -version = "2.0.0-beta.4" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca9756f4d32984ac454ae3155a276f6be69b424197bd3f0ca3c87cde72f41d63" +checksum = "77f5f9d66a8730d0fae62c26f3424f5751e5518086628a40b7ab6fca4a705034" dependencies = [ "futures-core", + "paste", "pin-project-lite", ] [[package]] name = "actix-tls" -version = "3.0.0-beta.3" +version = "3.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322b22e9238d065f331af0585089de8c36978fcc56f888054add4e4365b9916b" +checksum = "65b7bb60840962ef0332f7ea01a57d73a24d2cb663708511ff800250bbfef569" dependencies = [ "actix-codec", "actix-rt", @@ -145,24 +144,19 @@ dependencies = [ [[package]] name = "actix-utils" -version = "3.0.0-beta.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458795e09a29bc5557604f9ff6f32236fd0ee457d631672e4ec8f6a0103bb292" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "futures-core", - "futures-sink", - "log", + "local-waker", "pin-project-lite", ] [[package]] name = "actix-web" -version = "4.0.0-beta.3" +version = "4.0.0-beta.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9683dc8c3037ea524e0fec6032d34e1cb1ee72c4eb8689f428a60c2a544ea3" +checksum = "c503f726f895e55dac39adeafd14b5ee00cc956796314e9227fc7ae2e176f443" dependencies = [ "actix-codec", "actix-http", @@ -174,31 +168,36 @@ dependencies = [ "actix-utils", "actix-web-codegen", "ahash 0.7.0", - "awc", "bytes", + "cfg-if", + "cookie", "derive_more", "either", "encoding_rs", "futures-core", "futures-util", + "itoa", + "language-tags", "log", "mime", - "pin-project 1.0.5", + "once_cell", + "paste", + "pin-project", "regex", "serde", "serde_json", "serde_urlencoded", "smallvec", - "socket2", + "socket2 0.4.0", "time 0.2.25", "url", ] [[package]] name = "actix-web-codegen" -version = "0.5.0-beta.1" +version = "0.5.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8313dc4cbcae1785a7f14c3dfb7dfeb25fe96a03b20e5c38fe026786def5aa70" +checksum = "0d048c6986743105c1e8e9729fbc8d5d1667f2f62393a58be8d85a7d9a5a6c8d" dependencies = [ "proc-macro2", "quote", @@ -269,30 +268,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -[[package]] -name = "awc" -version = "3.0.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da7225ad81fbad09ef56ccc61e0688abe8494a68722c5d0df5e2fc8b724a200b" -dependencies = [ - "actix-codec", - "actix-http", - "actix-rt", - "actix-service", - "base64", - "bytes", - "cfg-if", - "derive_more", - "futures-core", - "log", - "mime", - "percent-encoding", - "rand 0.8.3", - "serde", - "serde_json", - "serde_urlencoded", -] - [[package]] name = "base-x" version = "0.2.8" @@ -390,6 +365,9 @@ name = "cc" version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -430,9 +408,9 @@ checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "cookie" -version = "0.14.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" +checksum = "ffdf8865bac3d9a3bde5bde9088ca431b11f5d37c7a578b8086af77248b76627" dependencies = [ "percent-encoding", "time 0.2.25", @@ -745,9 +723,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" dependencies = [ "bytes", "fnv", @@ -760,7 +738,6 @@ dependencies = [ "tokio", "tokio-util", "tracing", - "tracing-futures", ] [[package]] @@ -864,8 +841,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project 1.0.5", - "socket2", + "pin-project", + "socket2 0.3.19", "tokio", "tower-service", "tracing", @@ -927,6 +904,15 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "jobserver" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.47" @@ -938,9 +924,9 @@ dependencies = [ [[package]] name = "language-tags" -version = "0.2.2" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" [[package]] name = "lazy_static" @@ -973,6 +959,24 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +[[package]] +name = "local-channel" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f9a2d3e27ce99ce2c3aad0b09b1a7b916293ea9b2bf624c13fe646fadd8da4" + [[package]] name = "lock_api" version = "0.4.2" @@ -1055,7 +1059,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ - "socket2", + "socket2 0.3.19", "winapi", ] @@ -1208,39 +1212,25 @@ dependencies = [ "winapi", ] +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - [[package]] name = "pin-project" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96fa8ebb90271c4477f144354485b8068bd8f6b78b428b01ba892ca26caf0b63" dependencies = [ - "pin-project-internal 1.0.5", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "pin-project-internal", ] [[package]] @@ -1686,6 +1676,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "spin" version = "0.5.2" @@ -2002,9 +2002,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.2.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a" +checksum = "98c8b05dc14c75ea83d63dd391100353789f5f24b8b3866542a5e85c8be8e985" dependencies = [ "autocfg", "bytes", @@ -2091,16 +2091,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -2367,6 +2357,7 @@ dependencies = [ name = "zero2prod" version = "0.1.0" dependencies = [ + "actix-http", "actix-rt", "actix-web", "chrono", @@ -2377,3 +2368,32 @@ dependencies = [ "tokio", "uuid", ] + +[[package]] +name = "zstd" +version = "0.7.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "3.1.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.5.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" +dependencies = [ + "cc", + "libc", +] diff --git a/Cargo.toml b/Cargo.toml index c05f369..2bf0efe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ path = "src/main.rs" name = "zero2prod" [dependencies] -actix-web = "4.0.0-beta.3" +actix-web = "=4.0.0-beta.8" +actix-http = "=3.0.0-beta.8" serde = "1.0.115" config = { version = "0.10.1", default-features = false, features = ["yaml"] } sqlx = { version = "0.5.1", default-features = false, features = ["runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] } diff --git a/src/routes/subscriptions.rs b/src/routes/subscriptions.rs index 8db4b58..617a63b 100644 --- a/src/routes/subscriptions.rs +++ b/src/routes/subscriptions.rs @@ -9,11 +9,8 @@ pub struct FormData { name: String, } -pub async fn subscribe( - form: web::Form, - pool: web::Data, -) -> Result { - sqlx::query!( +pub async fn subscribe(form: web::Form, pool: web::Data) -> HttpResponse { + match sqlx::query!( r#" INSERT INTO subscriptions (id, email, name, subscribed_at) VALUES ($1, $2, $3, $4) @@ -25,9 +22,11 @@ pub async fn subscribe( ) .execute(pool.as_ref()) .await - .map_err(|e| { - println!("Failed to execute query: {}", e); - HttpResponse::InternalServerError().finish() - })?; - Ok(HttpResponse::Ok().finish()) + { + Ok(_) => HttpResponse::Ok().finish(), + Err(e) => { + println!("Failed to execute query: {}", e); + HttpResponse::InternalServerError().finish() + } + } }