Skip to content

Commit

Permalink
bug: running tokio inside tide (async-std)
Browse files Browse the repository at this point in the history
  • Loading branch information
chesedo committed May 24, 2022
1 parent dca744f commit db53405
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions api/users.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ projects = [
'hello-world-axum-app',
'authentication-rocket-app',
'hello-world-tide-app',
'postgres-tide-app',
]
4 changes: 2 additions & 2 deletions examples/tide/postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sqlx::{Executor, FromRow, PgPool};
use tide::{Body, Request};

async fn retrieve(req: Request<MyState>) -> 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)
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 7 additions & 1 deletion service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ secrets = ["sqlx-postgres"]

web-axum = ["axum", "sync_wrapper"]
web-rocket = ["rocket"]
web-tide = ["tide"]
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"]

0 comments on commit db53405

Please sign in to comment.