1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Provides Sqlite database for `axum`.
//!
//! ```rust
//! use axum::{Extension, response::Html, routing::get, Router};
//! use std::net::SocketAddr;
//! use axum_sqlite::*;
//!
//! #[tokio::main]
//! async fn main() {
//! let app = Router::new()
//! .route("/", get(index))
//! .layer(Database::new(":memory:").unwrap());
//! axum::Server::bind(&SocketAddr::from(([127, 0, 0, 1], 3000)))
//! .serve(app.into_make_service())
//! .await
//! .unwrap();
//! }
//!
//! async fn index(Extension(database): Extension<Database>) -> Html<&'static str> {
//! let connection = database.connection().unwrap(); // Do stuff with connection
//! Html("Hello, sqlite!")
//! }
//! ```
use Extension;
use ;
use SqliteConnectionManager;