diff --git a/Cargo.lock b/Cargo.lock index b6260a829..4d5273eea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,6 +241,7 @@ dependencies = [ "futures-lite", "num_cpus", "once_cell", + "tokio", ] [[package]] @@ -3967,6 +3968,7 @@ name = "shuttle-service" version = "0.2.7" dependencies = [ "anyhow", + "async-std", "async-trait", "axum", "chrono", diff --git a/api/users.toml b/api/users.toml index 40ddeb1cd..43c12742d 100644 --- a/api/users.toml +++ b/api/users.toml @@ -6,4 +6,5 @@ projects = [ 'hello-world-axum-app', 'authentication-rocket-app', 'hello-world-tide-app', + 'postgres-tide-app', ] diff --git a/examples/tide/postgres/src/lib.rs b/examples/tide/postgres/src/lib.rs index b36f5846a..88c0beef6 100644 --- a/examples/tide/postgres/src/lib.rs +++ b/examples/tide/postgres/src/lib.rs @@ -4,7 +4,7 @@ use sqlx::{Executor, FromRow, PgPool}; use tide::{Body, Request}; async fn retrieve(req: Request) -> tide::Result { - let id = req.param("id")?; + let id: i32 = req.param("id")?.parse()?; let todo: Todo = sqlx::query_as("SELECT * FROM todos WHERE id = $1") .bind(id) .fetch_one(&req.state().pool) @@ -40,8 +40,8 @@ async fn tide( let mut app = tide::with_state(state); app.with(tide::log::LogMiddleware::new()); - app.at("/todo/:id").get(retrieve); app.at("/todo").post(add); + app.at("/todo/:id").get(retrieve); Ok(app) } diff --git a/service/Cargo.toml b/service/Cargo.toml index 087edf461..6b576aeb9 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -47,4 +47,10 @@ secrets = ["sqlx-postgres"] web-axum = ["axum", "sync_wrapper"] web-rocket = ["rocket"] -web-tide = ["tide"] \ No newline at end of file +web-tide = ["tide"] + +# Tide does not have tokio support. So make sure async-std is compatible with tokio +# https://github.com/http-rs/tide/issues/791 +[dependencies.async-std] +version = "1" +features = ["tokio1"]