We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DatabaseConnection] is passed as State .with_state(state) in Axum Server but this don't work. [DatabaseConnection] can't be shared across threads.
[DatabaseConnection]
.with_state(state)
In examples/axum_example/api/src/lib.rs
examples/axum_example/api/src/lib.rs
... #[derive(Clone)] struct AppState { templates: Tera, conn: DatabaseConnection, } ... dotenvy::dotenv().ok(); let db_url = env::var("DATABASE_URL").expect("DATABASE_URL is not set in .env file"); let conn = Database::connect(db_url) .await .expect("Database connection failed"); let templates = ... let state = AppState { templates, conn }; ... let app = Router::new() .route("/", get(list_posts).post(create_post)) ... .with_state(state); ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
[DatabaseConnection]
is passed as State.with_state(state)
in Axum Server but this don't work.[DatabaseConnection]
can't be shared across threads.In
examples/axum_example/api/src/lib.rs
The text was updated successfully, but these errors were encountered: